By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,054 Members | 1,635 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,054 IT Pros & Developers. It's quick & easy.

How do a get to read the next line in a text file?

P: 13
Hi

I'm having problems with Java in reading the next line in a text file to execute to find a solution. My program is read the data from the text file and excute it and provide the answer on the screen.I've complied my program but can't get the program to read the next line in the text file. Please could someone help!!!Below is part of the code.

Expand|Select|Wrap|Line Numbers
  1. class Trianglesf
  2. {
  3.     public static void main(String[] args)
  4.     {
  5.         String input;
  6.         StringTokenizer st;
  7.  
  8.         textFile srcFile;
  9.  
  10.  
  11.  
  12.         do
  13.         {
  14.         // Open filenames given on command line
  15.          // for reading and writing.
  16.  
  17.         srcFile = new textFile(args[0], 'r');
  18.  
  19.         input=srcFile.readLine();
  20.  
  21.             st = new StringTokenizer(input);
  22.             if (st.countTokens() != 3)
  23.                 Screen.out.println("Error, please enter 3 numbers");
  24.  
  25.         }while(st.countTokens() != 3);
  26.         CheckSides(input);
  27.         srcFile.closeFile();
  28.         return;
  29.     }
  30.  
  31. }
  32.  
Thanks
Oct 31 '10 #1
Share this Question
Share on Google+
2 Replies


P: 6
What is the class "textFile"? Please share the class if you have it.
Nov 3 '10 #2

profall
P: 7
can't say ? what do you mean by executing the line after reading from the text file.
by the way <InputStreamReader object>.readLine(); reads a line and automatically brings the file pointer to next line.
can you give details for <textfile>
Nov 9 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.