Here you can find the source of saveFileFromByteArray(String filename, String pathDirectory, byte[] data)
Parameter | Description |
---|---|
filename | a parameter |
pathDirectory | a parameter |
data | a parameter |
public static boolean saveFileFromByteArray(String filename, String pathDirectory, byte[] data)
//package com.java2s; //License from project: Apache License import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; public class Main { /**// w w w .j a v a2 s . c o m * * @param filename * @param pathDirectory * @param data * @return Status of save opereration */ public static boolean saveFileFromByteArray(String filename, String pathDirectory, byte[] data) { Path path = Paths.get(pathDirectory); if (Files.isDirectory(path)) { Path completePathToSaveFile = Paths.get(path.toString(), filename); if (!Files.exists(completePathToSaveFile)) { try { Files.write(completePathToSaveFile, data); } catch (Exception e) { e.printStackTrace(); } return true; } else { return false; } } else { return false; } } }