3
我創建了一個智能卡應用程序,我可以在字節數組中存儲高達60KB的數據。但是當我多次閱讀數組時,我得到一個錯誤,我不能再訪問數據。Java卡從數組中讀取數據
代碼創建數組:
public void createFile(short fileID, short fileSize) {
short index = getFileIndex(fileID);
if(listFiles[index] == null) {
listFiles[index] = new byte[fileSize];
}
listfileSizes[index] = fileSize;
}
代碼讀取數據:
public byte[] readDataFromFile(short fileID, short fileOffset, short length) {
short selFileSize = getFileSize(fileID);
byte[] data = new byte[length];
if (selFileSize < (short)(fileOffset + length)) {
ISOException.throwIt(ISO7816.SW_FILE_FULL);
}
Util.arrayCopy(getFile(fileID), fileOffset, data, (short)0, length);
return (byte[])data;
}
代碼訪問閱讀:
short data_length = Util.getShort(buf, (short)(offset_cdata + 2));
short file_offset = Util.getShort(buf, offset_cdata);
if(p2 == (byte)0x01) {
Util.arrayCopy(myfile.readDataFromFile(myfile.keepassData1, file_offset, data_length), (short)0, buf, (short)0, data_length);
} else if (p2 == (byte)0x02) {
Util.arrayCopy(myfile.readDataFromFile(myfile.keepassData2, file_offset, data_length), (short)0, buf, (short)0, data_length);
}
當我重新安裝應用程序,我可以讀,寫,但只幾次直到數據被阻止。我得到錯誤6f00。
好還得感謝我會嘗試 – schisskiss