import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.stream.Stream;
public class Main {
public static void main(String[] args) throws IOException{
System.out.println("Hello world!");
// FileReader reader = new FileReader("/Users/eunsukkim/Desktop/text.txt");
try {
// Path path = Paths.get(Main.class.getResource("hyundaicar.txt").toURI());
Path path = Paths.get("/Users/eunsukkim/Desktop/text.txt");
Stream<String> filestream = Files.lines(path, Charset.defaultCharset());
filestream.forEach(l->System.out.println(l));
}
// catch (URISyntaxException ue) {
// ue.printStackTrace();
//
// }
catch (IOException ie) {
ie.printStackTrace();
} catch(Exception e){
e.printStackTrace();
}
}
}// Path path = Paths.get(Main.class.getResource("hyundaicar.txt").toURI());
// 텍스트 파일을 행으로 분리해서 행들의 스트림을 만들어준다.
댓글 영역