Article View: be.comp.programming
Article #12105Re: java : invoer van file
From: London Rain
Date: Sun, 16 Dec 2001 13:46
Date: Sun, 16 Dec 2001 13:46
42 lines
2038 bytes
2038 bytes
"Lennaart Dewulf" <streetbmx50@hotmail.com> schreef in bericht
news:z21T7.4635$Up1.858@afrodite.telenet-ops.be...
> Hallo,
>
> Voor mijn oefening voor t school moet ik van uit eenfile enkele regels
> inlezen en daar dan bewerkingen mee doen.
> Weet er iemand hoe je dit moet doen? Ik dacht dat het met
inputstreamReader
> was maar dit lijkt niet te lukken.
import java.io.*;
...
private BufferedReader fInputStream;
...
in een methode:
File inputFile = new File(dirName, fileName);
try {
fInputStream = new BufferedReader(new FileReader(inputFile));
}
catch (FileNotFoundException e) {
System.out.println("File " + fileName + " not found in " + dirName);
return;
}
try {
String line = (fInputStream.readLine()).trim();
while (line != null) {
// do iets met de lijn
line = (fInputStream.readLine());
}
fInputStream.close();
}
catch (IOException e) {
e.printStackTrace();
}
Vriendelijke groeten.
Technical Details
Message-ID:
<6B1T7.26059$zn7.2565302414@hebe.telenet-ops.be>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!isdnet!wanadoo.fr!opentransit.net!newsfeeds.belnet.be!news.belnet.be!ossa.telenet-ops.be!hebe.telenet-ops.be.POSTED!not-for-mailReferences:
<z21T7.4635$Up1.858@afrodite.telenet-ops.be>Show Full Headers
Complete Article Headers
X-Google-Language: DUTCH,ASCII-7-bit X-Google-Thread: fcea4,a27c109e923727a X-Google-Attributes: gidfcea4,public X-Google-ArrivalTime: 2001-12-16 05:46:47 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!isdnet!wanadoo.fr!opentransit.net!newsfeeds.belnet.be!news.belnet.be!ossa.telenet-ops.be!hebe.telenet-ops.be.POSTED!not-for-mail From: "London Rain" <londonrain@pandora.be> Newsgroups: be.comp.programming References: <z21T7.4635$Up1.858@afrodite.telenet-ops.be> Subject: Re: java : invoer van file Lines: 44 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6700 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700 Message-ID: <6B1T7.26059$zn7.2565302414@hebe.telenet-ops.be> Date: Sun, 16 Dec 2001 13:46:42 GMT NNTP-Posting-Host: 213.224.66.99 X-Complaints-To: abuse@pandora.be X-Trace: hebe.telenet-ops.be 1008510402 213.224.66.99 (Sun, 16 Dec 2001 14:46:42 CET) NNTP-Posting-Date: Sun, 16 Dec 2001 14:46:42 CET Organization: Telenet Internet