
为什么在包里面新建的file记事本中输入英文,运行结果会是数字?那我如果在file记事本中输入数字又会怎样?package liaoqi;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class CatchException {
public static void main(String[]args) {
FileInputStream fis=null;try {fis=new FileInputStream("test.txt");int b;while((b=fis.read())!=-1) {System.out.print(b);}}catch(FileNotFoundException e) {System.out.println("Error:"+e.getMessage());}catch(IOException e) {System.out.println("Error:"+e.getMessage());}finally {try {if(fis!=null) {fis.close();}}catch(IOException e) {}}}}
你读取文件时按字节读取的,相当于是把字符串编码成16进制以后读取显示,必然是数字啊