473,569 Members | 2,400 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

13 New Member
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
2 2847
Ian Smith
6 New Member
What is the class "textFile"? Please share the class if you have it.
Nov 3 '10 #2
profall
7 New Member
can't say ? what do you mean by executing the line after reading from the text file.
by the way <InputStreamRea der object>.readLin e(); reads a line and automatically brings the file pointer to next line.
can you give details for <textfile>
Nov 9 '10 #3

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

Similar topics

2
5500
by: David Thomas | last post by:
Hi there, I am trying to store data in a text file and output it to the browser using PHP. All very easy - if I was using English! the problem is, I want to use Japanese and I'm finding it a tad difficult to get PHP to understand. I have two files, a text file containing data to display and a php file with a script to display the data. I...
3
11772
by: H Brown New To It | last post by:
I am very new to Java. How would you go about making Java program that reads in a fixed length text file and pass the data into a table in an sql table? The text file data looks something like this: 123456John Smith Acme Boxes Inc 100 Someplace Drive 222222Sarah E. ConnorCyberdyne Systems Corp 1 Connorsbane Plaza...
2
2129
by: cricfan | last post by:
I'm parsing a text file to extract word definitions. For example the input text file contains the following content: di.va.gate \'di_--v*-.ga_-t\ vb pas.sim \'pas-*m\ adv : here and there : THROUGHOUT I am trying to obtain words between two literal backslashes (\ .. \). I am not able to match words between two literal backslashes using...
13
6098
by: Dan V. | last post by:
How do I create a one line text file with these control codes? e.g.: 144 = 0x90 and 147 = 0x93? I am trying to create a one line text file with these characters all one one row with no spaces. 1. 144 = 0x90 2. 147 = 0x93 3. STX = (^B = 2 = 0x2) 4. NUL = (^@ = 0 = 0x0)
8
2123
by: MLH | last post by:
Am trying to import 20,000+ lines of text in a file FTP'd from a UNIX platform to windows via FTP session in a DOS box. About 2000 records have multiple lines in them separated by CRLF's. That's not the idea. Each line was supposed to be a separate record. I don't know why the 2000 records having MULTIPLE lines of text are so stubborn....
1
3211
by: Saravanan | last post by:
I need to read in a text file as strings and then write some of these strings into another text file. The output file is in the working directory while the input text file is not. how can I implement... saran
6
14541
by: arf | last post by:
Hello, i have a problem where i need read dataset from text file and keep them into a vector. e.g. dataset: "0012 0033 00045 0044 0047" Based on this dataset, i need to keep every 4 numbers separately into a vector.
3
5702
by: maylee21 | last post by:
hi, anyone can help me figure out how to read data from a text file like this: 10980012907200228082002 and extract the data according to this kind of format: Record type 1 TY-RECORD PIC (1). ID-PARTICIPANT PIC (6).
2
6840
by: JamesGeddes | last post by:
Reading from a text file on your local computer is easy, but surely using a URL to point to a different location should work too? The code I have thus far is as follows using System; using System.IO; namespace csharp_station.howto { class TextFileReader
2
1851
by: Kalpesh Katwala | last post by:
I'm trying to read in a data file into an array. And split it into lines. I've a for loop which will parse the array, split the line (on ",") and execute another command. Here is the code. Problem is that PERL will parse only the last 11 lines from the data file. open TestList, "Testlist.dat" or die "Cannot open file to read data\n";...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7679
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3657
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2117
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.