BufferReaderとBufferInputStreamの違いと使い方
698 ワード
readerで終わるのは文字で読み込み、streamで終わるのはバイト形式です
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(new FileInputStream("resource/A.in"))));
//BufferedReader ,BufferedReader(Reader in),
//new BufferedReader(new InputStream(new FileInputStream("resource/A.in")))
while(sc.hasNextLine())
{
String str=sc.nextLine();
System.out.println(str);
}
}
}