![JAR search and dependency download from the Maven repository](/logo.png)
io.itit.FileUtil Maven / Gradle / Ivy
package io.itit;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
*
* @author skydu
*
*/
public class FileUtil {
public static void saveContent(byte bb[], File file) throws IOException {
try (FileOutputStream fos = new FileOutputStream(file);
ByteArrayInputStream bis = new ByteArrayInputStream(bb)) {
copy(bis, fos);
}
}
//
public static long copy(InputStream input, OutputStream output)
throws IOException {
byte[] buffer = new byte[4096];
long count = 0;
int n = 0;
while (-1 != (n = input.read(buffer))) {
output.write(buffer, 0, n);
count += n;
}
return count;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy