|
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
|