1、文件读取
@Test
public void testFileInputStream(){
InputStream in = null;
try {
in = new FileInputStream("f:/a/hello.txt");
int readCount = 0;
byte[] buffer = new byte[1024];
while((readCount = in.read(buffer, 0, 1024)) != -1){
String str = new String(buffer,0,readCount);
System.out.println(str);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally{
if(in != null){
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}