0
我想读取java中的bin文件。我在项目的文件夹中创建名称为doc的文件夹,并在doc文件夹中添加了bin文件。我想阅读这个代码;如何在eclipse中读取位于java项目文件夹中的bin文件
String fileName = "10.bin";
byte[] data = new byte[1024];
int readBytes;
try {
FileInputStream in = new FileInputStream(fileName);
while((readBytes = in.read(data)) != -1){
System.out.println("read " + readBytes + "bytes, and placed them into temp array named data");
}
in.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
命名为10.bin这个bin文件是doc文件夹,你可以在图片中看到
我不能与此代码访问文件。请帮帮我。
一些阅读:http://www.java-examples.com/read-file-using-fileinputstream – SabaRish 2015-02-23 12:33:58