import java.io.IOException;
public class Test {
public static void main(String[] args) {
try {
int temp = System.in.read();
System.out.println(temp);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
输出对应输入的ascii码,具体应是InputStream的子类FileInputStream中的native方法实现
/**
* Reads a subarray as a sequence of bytes.
* @param b the data to be written
* @param off the start offset in the data
* @param len the number of bytes that are written
* @exception IOException If an I/O error has occurred.
*/
private native int readBytes(byte b[], int off, int len) throws IOException;
temp如果用以下方法输出就是原值:
System.out.write(temp);