直接上代码:
private ArrayList<Integer> getSongIDsArrayList() {
ArrayList<Integer> songIDs = new ArrayList<>();
AssetManager assetManager = getResources().getAssets();getAssets();
try {
InputStream InputStream= assetManager.open("songsID.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(InputStream));//io进行流操作!
String line;
while ((line = br.readLine()) != null) {
if(!TextUtils.isEmpty(line)){
songIDs.add(Integer.valueOf(line));
}
}
} catch (IOException e) {
e.printStackTrace();
}
return songIDs;
}