I'm good at getting single-line ones, but if there's an opening character in the middle, is there any way to supplement this because the content after the opening character goes to the next line? (ex. Kanadara Mabasaaza) *: Opening character) What I want is a single string of Kanadara Mavasaaja, and the result is Kanadara Mavasaaja.
bufferedreader java newline
Add each line as below (reduce).
jshell is available from jdk 9 and above.
allinux@yhjung:~$ cat out.txt
abcde
fegfhi
jklmn
jshell> import java.io.*
jshell> import java.util.stream.*
jshell> BufferedReader reader = new BufferedReader(new FileReader("out.txt"))
reader ==> java.io.BufferedReader@a7e666
jshell> Stream<String> lines = reader.lines()
lines ==> java.util.stream.ReferencePipeline$Head@68bbe345
jshell> String result = lines.reduce((a, b) -> a + b).get()
result ==> "abcdefegfhijklmn"
jshell> reader.close()
© 2024 OneMinuteCode. All rights reserved.