Java Text File Write writeStringToFile(String jsonStr, File file)

Here you can find the source of writeStringToFile(String jsonStr, File file)

Description

write String To File

License

Apache License

Declaration

private static void writeStringToFile(String jsonStr, File file) 

Method Source Code


//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) {
        }
    }
}

Related

  1. writeStringToFile(String filename, String stringToWrite)
  2. writeStringToFile(String filename, String text)
  3. WriteStringToFile(String fn, String dest)
  4. writeStringToFile(String fullPath, byte[] fileBytes)
  5. writeStringToFile(String fullPath, String content)
  6. writeStringToFile(String macroContent, File file)
  7. writeStringToFile(String modifiedLine, String filePath)
  8. writeStringToFile(String path, String content)
  9. writeStringToFile(String path, String content)