This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
//here is my code but whenever I compile and run the program, it gives me the first line in the //file // here is the file: //1,2,3,4,5,6,7 //2541.36,2965.88,1965.32,1845.23,7021.11,9652.74,1469.36 //2513.45,1963.22,1568.35,1966.35,1893.25,1025.36,1128.36 //so how do I read the next line in this file
Please use code tags; they make the quoted code much easier to read.
Why are you using StringTokenizer in the first place? You should be able to get the String already parsed into tokens from a Scanner. And StringTokenizer is classed as legacy code in the API. You can save yourself a lot of bother with DecimalFormat objects by using the printf() method of System.out (PrintStream). If you are using Scanner, it consumes Exceptions, so you can simply call if(myScanner.IOException() != null) myScanner.IOException.printStackTrace(); which is better than simply catching Exception and then assuming it is a FileNotFoundException, as you do. BTW: If you insist on catching Exception, then your declaration of throws IOException is unnecessary.
You can use the nextLine() method of Scanner to read a line; you simply call it as many tiems as you like. Probably safest in a while(myScanner.hasNextLine()) loop. But if you are using double values, go through the Scanner class API for a method which reads doubles directly.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: how do I get the next line in the file and tokenize it