当前位置: 首页 > news >正文

电子烟网站建设/比较好的免费网站

电子烟网站建设,比较好的免费网站,个人博客网站模板源码,wordpress安装包文件夹前阵子写过一个小demo,有几个文件操作下相关的方法,留在这下次直接粘贴复制的 1 /**2 * 将byte数组保存为文件3 * 4 * param bfile5 * 字节数组6 * param filePath7 * 文件路径8 * param file…

前阵子写过一个小demo,有几个文件操作下相关的方法,留在这下次直接粘贴复制的

  1 /**
  2      * 将byte数组保存为文件
  3      * 
  4      * @param bfile
  5      *            字节数组
  6      * @param filePath
  7      *            文件路径
  8      * @param fileName
  9      *            文件名
 10      * @author zhangyanhua
 11      * @date 2019年6月5日 下午3:52:50
 12      */
 13     private boolean saveFile(byte[] bfile, String filePath, String fileName)
 14     {
 15         BufferedOutputStream bos = null;
 16         FileOutputStream fos = null;
 17         File file = null;
 18         try
 19         {
 20             File dir = new File(this.getFolder(filePath));
 21             if (!dir.exists() && !dir.isDirectory())
 22             {
 23                 dir.mkdirs();
 24             }
 25             file = new File(filePath + "\\" + fileName);
 26             File parentFile = file.getParentFile();
 27             if (!parentFile.exists() && !parentFile.isDirectory())
 28             {
 29                 parentFile.mkdirs();
 30             }
 31 
 32             fos = new FileOutputStream(file);
 33             bos = new BufferedOutputStream(fos);
 34             bos.write(bfile);
 35             return true;
 36         }
 37         catch (Exception e)
 38         {
 39             logger.error("保存文件出错 " + e);
 40             return false;
 41         }
 42         finally
 43         {
 44             if (bos != null)
 45             {
 46                 try
 47                 {
 48                     bos.close();
 49                 }
 50                 catch (IOException e1)
 51                 {
 52                     e1.printStackTrace();
 53                 }
 54             }
 55             if (fos != null)
 56             {
 57                 try
 58                 {
 59                     fos.close();
 60                 }
 61                 catch (IOException e1)
 62                 {
 63                     e1.printStackTrace();
 64                 }
 65             }
 66         }
 67     }
 68 
 69     /**
 70      * 获取conf.properties文件中的一个配置名称对应的值
 71      * 
 72      * @param name
 73      * @return
 74      * @author zhangyanhua
 75      * @date 2019年4月10日 上午10:50:39
 76      */
 77     private String getConfValue(String name)
 78     {
 79         InputStream inStream;
 80         try
 81         {
 82             Properties prop = new Properties();
 83             inStream = new FileInputStream(new File(confPath));
 84             prop.load(inStream);
 85             return prop.getProperty(name);
 86         }
 87         catch (FileNotFoundException e)
 88         {
 89             logger.error("配置文件" + confPath + "不存在!" + e);
 90         }
 91         catch (IOException e)
 92         {
 93             logger.error("初始化Properties失败!" + e);
 94         }
 95         return null;
 96     }
 97 
 98     /**
 99      * 处理目录字符串
100      * 
101      * @param folder
102      * @return
103      * @author zhangyanhua
104      * @date 2019年4月11日 上午11:26:13
105      */
106     private String getFolder(String folder)
107     {
108         if (StringUtils.isEmpty(folder))
109         {
110             folder = "";
111         }
112         else
113         {
114             if (!folder.endsWith("/"))
115             {
116                 folder += "/";
117             }
118         }
119         return folder;
120     }
121 
122     /**
123      * 获取指定目录下的全部文件
124      * 
125      * @param fileList
126      *            文件集合,递归调用
127      * @param path
128      *            需要获取文件的目录
129      * @return
130      * @author zhangyanhua
131      * @date 2019年4月10日 上午11:26:16
132      */
133     private List<File> getFileList(List<File> fileList, String path)
134     {
135         if (StringUtils.isEmpty(path))
136         {
137             logger.error("目标文件不存在或者文件夹是空的!");
138             return null;
139         }
140 
141         File file = new File(path);
142         if (file.exists())
143         {
144             File[] files = file.listFiles();
145             if (null == files || files.length == 0)
146             {
147                 logger.error("目标文件不存在或者文件夹是空的!");
148                 return null;
149             }
150             else
151             {
152                 for (File file1 : files)
153                 {
154                     if (file1.isDirectory())
155                     {
156                         // 获取文件绝对路径
157                         getFileList(fileList, file1.getAbsolutePath());
158                         continue;
159                     }
160                     else
161                     {
162                         fileList.add(file1);
163                     }
164                 }
165             }
166         }
167         else
168         {
169             logger.error("目标文件不存在!");
170         }
171         return fileList;
172     }

 

转载于:https://www.cnblogs.com/yanh0606/p/10983103.html

http://www.jmfq.cn/news/4758157.html

相关文章:

  • 免费网站设计培训班/产品推广方案模板
  • 做网站架构的软件/如何搭建公司网站
  • 低成本门户网站开发/腾讯广告代理商加盟
  • 网页游戏网站源码/如何制作一个网站
  • 建一个app要多少钱/宁德seo培训
  • 安阳网站建设公司/游戏推广平台
  • 建站快车凡科/百度文库首页官网
  • 一学一做征文网站/网页设计模板
  • 太原市网站制作/企业培训视频
  • 做游戏代练网站/怎样在百度上发布信息
  • 做网站找哪家好/亚马逊跨境电商开店流程及费用
  • 网站设计工作室公司/亚马逊跨境电商
  • 长春关键词排名公司/关键词优化排名查询
  • 好用的企业邮箱/北京中文seo
  • 在dw上做网站首页导航栏/自己想开个网站怎么弄
  • 长安响应式网站建设/百度搜索智能精选入口
  • 东莞网站建设定制/seo有哪些作用
  • 扬州学做网站培训多少钱/百度网站排名seo
  • 做单平台网站制作/百度推广的方式
  • 网站设计作业/如何做个网站推广自己产品
  • 注册网站域名的入口是/网站关键词优化排名公司
  • 模板 网站/重庆高端网站seo
  • 网站模板下载后如何使用/cpa游戏推广联盟
  • 服务器网站建设/柳州今日头条新闻
  • 辽宁省造价信息网/app关键词排名优化
  • 官方网站开发招标须知/万能优化大师下载
  • 做的网站必须放在idc机房吗/肇庆seo排名
  • 开网站做什么/优化服务平台
  • 网站建设多少钱杭州/seo赚钱培训课程
  • 政府网站是哪个建设的/搜索引擎优化是什么意思啊