Here you can find the source of writeToFile(File file, byte[] content)
Parameter | Description |
---|---|
file | a parameter |
content | a parameter |
Parameter | Description |
---|---|
Exception | an exception |
public static void writeToFile(File file, byte[] content) throws Exception
//package com.java2s; //License from project: Apache License import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; public class Main { /**/*from ww w . j av a 2 s .c om*/ * Write function for JVM >= 1.7 * @param file * @param content * @throws Exception */ public static void writeToFile(File file, byte[] content) throws Exception { Files.write(Paths.get(file.getPath()), content, StandardOpenOption.SYNC, StandardOpenOption.WRITE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.CREATE); } }