Here you can find the source of save(File file, byte[] bytes)
Parameter | Description |
---|---|
file | the file |
bytes | the byte array |
Parameter | Description |
---|---|
IOException | an exception |
public static void save(File file, byte[] bytes) throws IOException
//package com.java2s; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; public class Main { /**/*from w ww.j a va 2 s.c o m*/ * Saves a byte array to a file. * * @param file * the file * @param bytes * the byte array * @throws IOException */ public static void save(File file, byte[] bytes) throws IOException { OutputStream os = new FileOutputStream(file); try { os = new BufferedOutputStream(os); for (int i = 0; i < bytes.length; i += 2048) { int len = Math.min(bytes.length - i, 2048); os.write(bytes, i, len); } } finally { os.close(); } } }