文件输出流 public static void write(String filePath, byte[] source){ File newFile = new File(filePath); if (!newFile.getParentFile().exists()) { newFile.mkdir(); } FileOutputStream fileOutputStream = null; BufferedOutputStream bufferedOutputStream = null; try { fileOutputStream = new FileOutputStream(newFile); bufferedOutputStream = new BufferedOutputStream(fileOutputStream); bufferedOutputStream.write(source); bufferedOutputStream.flush(); bufferedOutputStream.close(); fileOutputStream.close(); } catch (IOException e) { e.printStackTrace(); } finally { if (fileOutputStream != null) { try { fileOutputStream.close(); } catch (IOException e) { e.printStackTrace(); } } if (bufferedOutputStream != null) { try { bufferedOutputStream.close(); } catch (IOException e) { e.printStackTrace(); } } } }
生成文件(xml,text.....)
最新推荐文章于 2023-01-02 04:30:08 发布