Here you can find the source of writeStringToFile(String jsonStr, File file)
private static void writeStringToFile(String jsonStr, File file)
//package com.java2s; //License from project: Apache License import java.io.*; public class Main { private static void writeStringToFile(String jsonStr, File file) { try {/* w w w. j a v a2 s . c o m*/ OutputStream out = new FileOutputStream(file); ByteArrayInputStream in = new ByteArrayInputStream(jsonStr.getBytes()); byte[] buffer = new byte[1024]; int len = 0; while ((len = in.read(buffer, 0, 1024)) != -1) { out.write(buffer, 0, len); } in.close(); out.close(); } catch (Exception e) { } } }