文件工具类
/*** 文件处理工具类* * @author ruoyi*/
public class FileUtils extends org.apachemons.io.FileUtils
{public static String FILENAME_PATTERN = "[a-zA-Z0-9_\-\|\.\u4e00-\u9fa5]+";/*** 输出指定文件的byte数组* * @param filePath 文件路径* @param os 输出流* @return*/public static void writeBytes(String filePath, OutputStream os) throws IOException{FileInputStream fis = null;try{File file = new File(filePath);if (!ists()){throw new FileNotFoundException(filePath);}fis = new FileInputStream(file);byte[] b = new byte[1024];int length;while ((length = ad(b)) > 0){os.write(b, 0, length);}}catch (IOException e){throw e;}finally{if (os != null){try{os.close();}catch (IOException e1){e1.printStackTrace();}}if (fis != null){try{fis.close();}catch (IOException e1){e1.printStackTrace();}}}}/*** 删除文件* * @param filePath 文件* @return*/public static boolean deleteFile(String filePath)
本文发布于:2024-01-28 21:29:48,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170644859310412.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |