DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Threaded View

  1. #1
    Join Date
    Mar 2007

    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;
    br = new BufferedReader(new FileReader("C:/WebRoot/encodings.txt"));
    while ((tempStr = br.readLine()) != null)
    catch (FileNotFoundException ex) {

    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()){
    System.out.println(map[i][0]+" " + " "+map[i][1]);
    }//End Of While Loop

    Attached Files Attached Files

Similar Threads

  1. Replies: 4
    Last Post: 12-29-2008, 08:25 AM
  2. Exception in thread "main"
    By SeanB in forum Java
    Replies: 3
    Last Post: 04-02-2007, 05:51 PM
  3. Getting a thread to throw an exception
    By jjamesis in forum Java
    Replies: 4
    Last Post: 04-02-2007, 05:37 PM
  4. Replies: 7
    Last Post: 04-02-2007, 05:35 PM
  5. Exception in thread "main"
    By Sean in forum Java
    Replies: 0
    Last Post: 03-29-2002, 07:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center