Article View: borland.public.jbuilder.java.language
Article #16183Re: Reading Files a line at a time
From: Tom Heagy
Date: Wed, 24 Mar 1999 00:00
Date: Wed, 24 Mar 1999 00:00
33 lines
1295 bytes
1295 bytes
Try the following:
import java.io.*;
try {
RandomAccessFile aFile = new RandomAccessFile("TestFrame.java",
"r"); // r = read-only rw=read/write
String sLine = aFile.readLine();
while (sLine != null) {
System.out.print(sLine);
sLine = aFile.readLine();
}
aFile.close();
}
catch (IOException e) {
System.out.println("IO Error");
}
-Tom
Frank Packenham wrote:
> I can use FileInputStream and it's read method to read a file a byte at a
> time, but I'd like to Read a line into a String().
>
> Surely there's a java class I can't find which does this
>
> -------
> Frank Packenham
> Senior Analyst/Developer
> NeuroFlex Pty Ltd.
Technical Details
Message-ID:
<36F8F2B2.4A7E761D@sciatl.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7d9l8r$mk98@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,abfd8414dd27ad8e X-Google-Attributes: gidf74b3,public From: Tom Heagy <tom.heagy@sciatl.com> Subject: Re: Reading Files a line at a time Date: 1999/03/24 Message-ID: <36F8F2B2.4A7E761D@sciatl.com> X-Deja-AN: 458381662 Content-Transfer-Encoding: 7bit References: <7d9l8r$mk98@forums.borland.com> To: Frank Packenham <frank@NeuroFlex.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language