public class FileUtil { public static byte[] getFileBytes(File file) { FileInputStream fileInputStream = null; byte[] bytes = null; try { fileInputStream = new FileInputStream(file); bytes = new byte[fileInputStream.available()]; fileInputStream.read(bytes); } catch (Exception e) { e.printStackTrace(); } finally { if (fileInputStream != null) { try { fileInputStream.close(); } catch (IOException e) { e.printStackTrace(); } } } return bytes; } public static byte[] getFileBytes(String filePath) { File file = new File(filePath); return getFileBytes(file); } public static void wirteDataToFile(String savePath, byte[] data) throws Exception { FileOutputStream fileOutputStream = null; try { fileOutputStream = new FileOutputStream(savePath); fileOutputStream.write(data); fileOutputStream.flush(); } catch (Exception var11) { throw var11; } finally { try { if (fileOutputStream != null) { fileOutputStream.close(); } } catch (IOException var10) { } } } }
一个fileUtil
最新推荐文章于 2022-09-21 09:48:18 发布