DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Threaded View

  1. #1
    Join Date
    Mar 2007
    Posts
    3

    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
    }

    }
    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

Bookmarks

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
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links