为什么第一行提前换行
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
public class Demo {
public static void main(String[] args) throws IOException{
Demo demo = new Demo();
demo.go("E:\\testdata\\directory1\\text1.txt");
}
public void go (String fn) throws IOException{
if(! (new File(fn)).exists()) {
IOException ioe = new IOException("文件不存在");
throw (ioe);
}else {
FileInputStream fis = new FileInputStream(fn);
fis.read();
int aa;
int bb = 1;
while((aa = fis.read()) != -1) {
if((bb++ % 10) == 0) {
System.out.println();
}
if(aa <= 0xF) {
System.out.print(0);
}
System.out.print(Integer.toHexString(aa) + ",");
}
fis.close();
}
}
}代码是这样写的,文件text1.txt中的内容是:There is a very beautiful city called Loulan,which locates in the west of ancient China.,输出结果却是:
68,65,72,65,20,69,73,20,61,
20,76,65,72,79,20,62,65,61,75,
74,69,66,75,6c,20,63,69,74,79,
20,63,61,6c,6c,65,64,20,4c,6f,
75,6c,61,6e,2c,77,68,69,63,68,
20,6c,6f,63,61,74,65,73,20,69,
6e,20,74,68,65,20,77,65,73,74,
20,6f,66,20,61,6e,63,69,65,6e,
74,20,43,68,69,6e,61,2e,
为何第一行提前了一下?