Skip to content

Instantly share code, notes, and snippets.

@rmg007
Created October 29, 2022 16:37
Show Gist options
  • Save rmg007/b7699a8dcd325739f6444707b2a80733 to your computer and use it in GitHub Desktop.
Save rmg007/b7699a8dcd325739f6444707b2a80733 to your computer and use it in GitHub Desktop.
BufferedReade rBufferedWriter Example
import java.io.*;
public class BufferedReaderBufferedWriterExample {
static String filePath = "/Users/ryan/Desktop/file.txt";
public static void main(String[] args) throws IOException {
//String word = "hello java";
//char[] chars = word.toCharArray();
//try(FileWriter fw = new FileWriter(filePath);
//BufferedWriter bw = new BufferedWriter(fw)){
// bw.write(word);
// bw.newLine();
// bw.write(chars);
//}
try(FileReader fr = new FileReader(filePath);
BufferedReader br = new BufferedReader(fr)){
//List<String> list = br.lines().filter(l -> l.contains("3")).toList();
//System.out.println(list);
//System.out.println(br.readLine());
//System.out.println(br.readLine());
//br.mark(200);
//System.out.println(br.readLine());
//System.out.println(br.readLine());
//br.reset();
//System.out.println(br.readLine());
//System.out.println(br.readLine());
String line;
while ((line = br.readLine()) != null){
System.out.println(line);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment