_118_Java_標準輸入輸出流
阿新 • • 發佈:2018-12-11
----------------------------------
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import org.junit.Test; public class _001_StandardInputOrOutputStream { @Test public void test() { InputStream in = System.in; InputStreamReader isr= new InputStreamReader(in); BufferedReader br = new BufferedReader(isr); try { String readLine = br.readLine(); System.out.println(readLine); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }finally { if(br!=null) { try { br.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } }