1
蔭試圖讀取二進制文件到存儲器,並通過存儲塊的起始地址,以本機函數:訪問字節元素
Memory image = new Memory(length);
int offset = 0;
int numRead = 0;
try
{
while (offset < image.size() && (numRead = in.read(image.getByteArray(0,(int)image.size()), offset, (int)image.size() - offset)) >= 0)
{
offset += numRead;
}
if (offset < image.size())
{
throw new IOException("Could not completely read file " + fileFileName.getName());
}
in.close();
}
catch(Exception IOException)
{
System.out.println("\nError Occured in try block!!!");
}
byte imageByte = image.getByte(0);
的問題是,imageByte的值是 - 60而不是127.我通過採取一個字節數組(而不是內存)並將文件讀入它來檢查。但它也顯示了數組[0] 127。這裏有什麼問題?
請添加您的決議答案並將其標記爲例外。 – lockstock 2012-03-26 06:08:21