Here you can find the source of writeStringToFile(String fullPath, byte[] fileBytes)
public static boolean writeStringToFile(String fullPath, byte[] fileBytes)
//package com.java2s; //License from project: Apache License import java.io.BufferedOutputStream; import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.Writer; public class Main { public static boolean writeStringToFile(String fullPath, String content) { try {//from w ww . j ava 2s . com Writer output = null; File file = new File(fullPath); if (!file.exists()) { file.createNewFile(); } output = new BufferedWriter(new FileWriter(file)); output.write(content); output.close(); } catch (IOException ex) { ex.printStackTrace(); return false; } return true; } public static boolean writeStringToFile(String fullPath, byte[] fileBytes) { try { BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(fullPath)); bos.write(fileBytes); bos.flush(); bos.close(); } catch (IOException ex) { ex.printStackTrace(); return false; } return true; } /** * Closes InputStream and/or OutputStream. It makes sure that both streams * tried to be closed, even first throws an exception. * * @throw IOException if stream (is not null and) cannot be closed. * */ protected static void close(InputStream iStream, OutputStream oStream) throws IOException { try { if (iStream != null) { iStream.close(); } } finally { if (oStream != null) { oStream.close(); } } } }