我正嘗試在文件的開始處以3個短褲讀取.csv文件。我需要閱讀它們,我正在設置一個變量,但它似乎沒有拉入正確的數據。在RandomAccessFile中讀短褲.csv
private short M = 0;
private short rootPtr = 0;
private short N = 0;
RandomAccessFile file;
private short[] TP; // array of TPs for one node
private String[] KV; // array of KVs for one node
private short[] DRP; // array of DRPs for one node
private int nodesRead; // iterator for nodes read
private int sizeOfDataRec; // stores size of data record: (M - 1) * (7) + 2
// sets values from header record
file.seek(0);
M = file.readShort();
rootPtr = file.readShort();
N = file.readShort();
sizeOfDataRec = (M - 1) * (7) + 2; // sets size of data record
TP = new short[M];
KV = new String[M - 1];
DRP = new short[M - 1];
文件的第3個短褲應該是05,11,22,但我得到12344時,我在此位
的建議我建議使用一個圖書館閱讀CSV文件,如果你沒有限制。 (https://commons.apache.org/proper/commons-csv/) – dumitru