package com.company; import javafx.scene.shape.Line; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import static java.lang.System.*; /** * Created by wb-wl228081 on 2017/8/11. */ public class TransStreamDemo { public static void main(String[] args) throws IOException { // 调用read2方法 read2(); // 结束标志控制台输出“a” System.out.println("a"); } public static void read2() throws IOException{ //字节流 InputStream in = System.in; //将字节流转换成字符流,转换流 InputStreamReader isr = new InputStreamReader(in); //字节流 BufferedReader bufr = new BufferedReader(isr); //bufr.readLine(); String line =""; while((line=bufr.readLine())!=""){ //多种判断条件,一个满足即可,equals/contains/endswith if(line.equals("over")||line.contains("goodbye")||line.endsWith("oo")){ break;} //获取不同平台的换行符 String LINE_SEPARATOR = System.getProperty("line.separator"); System.out.println(line.toUpperCase()+"\r\n"+LINE_SEPARATOR+line.hashCode()); //System.out.println(line.hashCode()); } } }