文字列オブジェクトがあります。を使用して書き込みbufferedReader.readline()
ます。sの内容をログアウトしましたが、logcatでそれらを確認できるので、nullではないことがわかります。後でsを使用して呼び出しますString.split
が、NPEを取得しています。なぜ、すでに入力されているのでnullではないのですか?
ありがとう。
String cachePath = getCacheDir().getAbsolutePath();
FileReader fr = null;
try {
fr = new FileReader(cachePath + "/dbcache/" + "cacheTextFile.txt");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
BufferedReader br = new BufferedReader(fr);
String s = null;
try {
while((s = br.readLine()) != null) {
Log.e(TAG, "s = " + s);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
fr.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
HashMap<String, String> hash = new HashMap<String, String>();
Log.e(TAG, "about to call on s"+s.length());
String[] arr = s.split(",");
for(int i = 0; i < arr.length; i=i+2){
String key = arr[i].toString();
hash.put(key, "-1");
Log.e(TAG, "hash key = " + hash.get(key));
}