Created
October 29, 2022 16:37
-
-
Save rmg007/b7699a8dcd325739f6444707b2a80733 to your computer and use it in GitHub Desktop.
BufferedReade rBufferedWriter Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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