文件流操作
using System.IO; byte[] buffArr = new byte[1024]; using (FileStream fs = new FileStream(@"D:\123.txt", FileMode.Open, FileAccess.Read)) { using (BinaryReader sr = new BinaryReader(fs)) { buffArr = sr.ReadBytes(1024); } }
LZ 要的是 JAVA代码
应该是了。。。
Java看这里:http://blog.163.com/jameswh_2004/blog/static/44698131201032804741644/
public static byte[] readFile(String filename) throws IOException ...{
File file =new File(filename);
if(filename==null || filename.equals(""))
...{
throw new NullPointerException("无效的文件路径");
}
long len = file.length();
byte[] bytes = new byte[(int)len];
BufferedInputStream bufferedInputStream=new BufferedInputStream(new FileInputStream(file));
int r = bufferedInputStream.read( bytes );
if (r != len)
throw new IOException("读取文件不正确");
bufferedInputStream.close();
return bytes;
}