1 Attachment(s)
Exception in thread "main" java.util.NoSuchElementException
I am reading a file "encodings.txt" into a two dimensional array, this file contains url encodings, it works perfectly fine down the half of the fiel but then i get a weired kind of exception i.e."Exception in thread "main" java.util.NoSuchElementException", i personally dont think that this is coz of tokenizer running out of tockens, since a new token is createn each time loop traverses. I someone knows the problem plz let me know.
the sample code and the encodings.txt (see attachment) file are given
package fielreader;
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
ArrayList line = new ArrayList();
String tempStr = null;
BufferedReader br=null;
try
{
br = new BufferedReader(new FileReader("C:/WebRoot/encodings.txt"));
while ((tempStr = br.readLine()) != null)
line.add(tempStr);
}
catch (FileNotFoundException ex) {
ex.printStackTrace();
}
String [][] map = new String[line.size()][2];
for (int i = 0; i < map.length; i++)
{
tempStr = (String) line.get(i);
StringTokenizer st = new StringTokenizer(tempStr);
while (st.hasMoreTokens()){
map[i][0]=st.nextToken();
map[i][1]=st.nextToken();
}
System.out.println(map[i][0]+" " + " "+map[i][1]);
}//End Of While Loop
}
}