아래 메서드는 AsynTask의 여러 위치에서 호출되고 있습니다. Android 용으로 코딩되었습니다. ConcurrentModificationException을 가져 오는 중입니다.ConcurrentModificationException
private final Object lock = new Object();
public static String saveJsonFile(File dir, String name, JSONObject data) {
final File file = new File(dir.getPath() + File.separator + name);
try {
file.createNewFile();
} catch (final IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
BufferedWriter printWriter = null;
try {
printWriter = new BufferedWriter(new FileWriter(file), 8192);
synchronized(lock) {
if (data != null)
data.write(printWriter); // java.util.ConcurrentModificationException
//...
이 JSONObject.write입니다()? http://developer.android.com/reference/org/json/JSONObject.html에 도착하지 않았습니다. –
파일에 데이터를 쓰는 데 추가 된 사용자 정의 방법입니다. 나는 Jar 파일로 컴파일 된 것을 볼 수 없다. 실제로 그것은 org.json.douglascrockford.JSONObject입니다. –
@ Vinayak.B 그 클래스에는 기본 맵을 변경하는 두 가지 메소드 (다른 생성자)가 있습니다. JSONObject에'put' 또는'popuplate'를 호출 한 적이 있습니까? –