[Java 12 IO] InputStream inputStream = System.in; 的读操作 read() != -1
2014-06-06 10:48
555 查看
InputStream 的另一种方式读
package com.qunar.basicJava.javase.io; import java.io.IOException; import java.io.InputStream; /** * Author: libin.chen@qunar.com Date: 14-6-5 21:02 */ public class SystemDemo05 { public static void main(String[] args) throws IOException { InputStream inputStream = System.in; StringBuffer stringBuffer = new StringBuffer(); System.out.println("请输入内容 : "); int temp = 0; while <strong>((temp = inputStream.read()) != -1) {</strong> char c = (char)temp; if (c == '\n') break; stringBuffer.append(c); } System.out.println("输出的内容是 : " + stringBuffer); inputStream.close(); System.out.println(System.getProperty("file.encoding")); } }
相关文章推荐
- [Java 12 IO] InputStream inputStream = System.in; 的读操作 read() != -1
- 流 JAVA IO 基本小结 通过一行常见的代码讨论:new BufferedReader(new InputStreamReader(System.in))
- 流 JAVA IO 基本小结 通过一行常见的代码讨论:new BufferedReader(new InputStreamReader(System.in))
- Java IO操作——System类对IO的支持(System.out、System.err、System.in)
- Think in Java(12)-IO
- java.io.InputStream.read和java.io.OutputStream.write
- java-System.in.read()方法与java.util.Scanner类的读取输入差别
- Can not find a java.io.InputStream with the name [inputStream] in the invocation stack问题解决
- at java.io.ObjectInputStream$PeekInputStream.readFully
- [Java] new BufferedReader(new InputStreamReader(System.in)) 从控制台输入
- In Java, how do I read/convert an InputStream to a String? - Stack Overflow
- Java的IO操作(三) - 对象的序列化、ObjectInputStream和ObjectOutputStream类
- Can not find a java.io.InputStream with the name [downloadFile] in the invocation stack问题解决
- MapReduce Error: java.io.EOFException at java.io.DataInputStream.readFully(DataInputStream.java:197)
- (Struts2文件下载)Can not find a java.io.InputStream with the name [inputStream] in the invocation stack
- java.io.ObjectOutputStream.putFields()和java.io.ObjectInputStream. readFields()
- Can not find a java.io.InputStream with the name [downloadFile] in the invocation stack问题解决
- Java流操作,InputStream、OutputStream及子类FileInputStream、FileOutputStream;BufferedInpu
- struts2文件的下载,Can not find a java.io.InputStream with the name [inputStream] in the invocation stack. Check the tag specified
- strut2下载时候的一种异常 Can not find a java.io.InputStream with the name [inputStream] in the invocation stack