View Single Post
  #1 (permalink)  
Old 08-01-2007, 03:24 AM
jason27131 jason27131 is offline
Member
 
Join Date: Jul 2007
Posts: 18
jason27131 is on a distinguished road
help with file reader
how do i actually run file reader?
i know i have to create a new object, but what do i
enter as the argument? This is the code.

Code:
import java.io.*;


public class FileAccess {


public static void displayFile(String f) throws IOException {
FileReader fr = new FileReader(f);
BufferedReader br = new BufferedReader(fr);

String line = br.readLine();

while (line != null) {


System.out.println(line);


line = br.readLine();
}

br.close();
fr.close();
}


public static void writeToFile(String outfile, String s) throws IOException {
FileOutputStream fs = new FileOutputStream(outfile);
PrintStream p = new PrintStream(fs);


p.println(s);

p.close();
fs.close();
}
}

ty very much
Reply With Quote
Sponsored Links