String sp=",";
String se="\n";
try{FileOutputStream outfs = openFileOutput("Apppackname.txt", MODE_APPEND);
outfs.write(data_1.mAppNaem.getBytes());
outfs.write(sp.getBytes());
outfs.write(data_1.mAppPackge.getBytes());
outfs.write(sp.getBytes());
outfs.close();
}catch(IOException e){}
위의 코드가 파일 입력부분입니다. 이것을 통해 저장된 txt 내용이
mo131107,com.example.mo131107,Preferences Test,com.holim.test.pref01,Android_6_1_239p,com.example.android_6_1_239p,어플목록,co.kr.pluu.appinfo,
마지막으로.
try {
FileInputStream stream = openFileInput("Apppackname.txt");
InputStreamReader reader = new InputStreamReader(stream);
StreamTokenizer tokens = new StreamTokenizer(reader);
tokens.quoteChar(','); // 자를 범위지정
while (tokens.nextToken() != tokens.TT_EOF) {
String appname = tokens.sval;
tokens.nextToken();
String apppack = tokens.sval;
arGeneral.add(appname + " [ " + apppack + " ] ");
pacageNm.add(apppack);
};
stream.close();
} catch (IOException e) {
Toast.makeText(this, "선택된 어플이 없습니다.", 0).show();
}
가 파일을 읽는쪽입니다.
저의 예상으로는
mo131107[com.example.mo131107]
Preferences Test[com.holim.test.pref01]
Android_6_1_239p[com.example.android_6_1_239p]
어플목록[co.kr.pluu.appinfo]
이렇게 출력이 되어야 하는데.;;; 실상은...
mo131107[com.example.mo131107]
Preferences [Test]
com.holim.test.pref01[Android]
null[null]
null[null]
null[null]
p[com.example.android_6_1_239p]
어플목록[co.kr.pluu.appinfo]
이렇게 출력이 됩니다....
뭐가 문제일까요 ... 띄어쓰기와 "_" 것을 구분자로 사용해서 그런것인지... 참 난감하네요 ㅠㅠ
도와주세요 ...