package com.knock.io;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import org.junit.Test;
/**
* @date 160802am
* 测试一下怎么把文件传到程序中
* */
public class KaInput {
@Test
public void test(){
File src = new File("D:/test/a.txt");
InputStream is = null;
try {
is = new FileInputStream(src);
byte[] car = new byte[1024];
int len;
while(-1!=(len=(is.read(car)))){
String str = new String(car,0,len);
System.out.println(str);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally{
try {
if(null!=is){
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}