所以我在 MyApplicationProject/assets 中有这段代码和一个文本文件。我正在尝试读取它并将其放入按行和“,”分割的二维数组中,我不断收到 IOException。先感谢您
public String[][] stopData() throws IOException {
AssetManager assetManager = getAssets();
InputStream input;
input = assetManager.open("stops.txt");
int size = input.available();
byte[] buffer = new byte[size];
input.read(buffer);
input.close();
String content = new String(buffer);
String[] lines = content.split("/n");
String[][] stopData = new String[lines.length][];
for (int i=0; i < lines.length; i++) {
stopData[i] = lines[i].split(",");
if (stopData[i].length != 9 ) {
Log.d(TAG,"odd length " + stopData.toString() );
}
}
return stopData;
}