Java 基本输入输出(备忘)

简述:

用java的输入输出流,读入一行string 并做输出


知识点:

java的IO流使用


代码:


package test.inputstream;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

public class TestInput {
	public static void main(String[] args){
		InputStream inputStream = System.in;
		InputStreamReader inputStreamReader = new InputStreamReader(inputStream); 
		BufferedReader bufferReader = new BufferedReader(inputStreamReader); 
		try{
			String lineStr = null;
			while(!(lineStr = bufferReader.readLine()).equals("")){
				System.out.println(lineStr);
			}
		}catch(IOException e){
			e.printStackTrace();
		}
		try{
			bufferReader.close();
			inputStreamReader.close();
			inputStream.close();
		}catch(IOException e){
			e.printStackTrace();
		}
	}
}


输出:



你可能感兴趣的:(Java)