/ Published in: Java
Stores country name code and capital in an array and returns it. (not completed)
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
package xmlReader; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FilePermission; import java.io.FileReader; import java.io.IOException; import java.nio.file.Files; import java.util.StringTokenizer; public class CapitalsReader { String fileName; int quoteCount = 0; public CapitalsReader() { } CapitalsReader capitals_reader = new CapitalsReader(); capitals_reader.Read(); } { try { int lineNumber = 0; int tokenNumber = 0; while( (fileName = br.readLine()) != null) { lineNumber++; tokenNumber = 0; // skip second line if(lineNumber!=1) { while (stringTokenizer.hasMoreTokens()) { if(tokenNumber == 0 && lineNumber ==4) { } tokenNumber++; /* TO DO code to check for the tokens you want so you can insert the correct elements into the String [][] capitals. Use the fact that the country name begins after the first " and ends at the second, the country code runs from the fifth " to the 6th and the capital from the 15th " to the 16th. Once you've processed the capital, break ou of the while loop. */ //if() break; } lineNumber++; } } // TODO Auto-generated catch block e.printStackTrace(); // TODO Auto-generated catch block e.printStackTrace(); } finally { // do whatever you want here i.e. print something like "finished" } return capitals; } }
URL: https://github.com/mledoze/countries/blob/master/countries.xml