日期:2014-05-20  浏览次数:20557 次

请问 InputStream 中的 read() 方法返回的整数是什么?
temp 的整数值是什么?是字符的什么码?
Java code

import java.io.*;
public class Iojava {
    public static void main(String[] args) throws Exception {
    File f=new File("D:"+File.separator+"text.txt");
    InputStream In=null;
    In=new FileInputStream(f);
    byte[] b=new byte[1024];
    int temp=0;
    int len=0;
    while((temp=In.read())!=-1)
    {
        System.out.print("temp 的值为:"+temp);
        len++;
        System.out.println("   len的值为"+len);
        
    }
    In.close();
    }}


结果:

temp 的值为:196 len的值为1
temp 的值为:227 len的值为2
temp 的值为:186 len的值为3
temp 的值为:195 len的值为4

------解决方案--------------------
unicode码的10进制数