打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
java对文件操作例子辅助类1
 
package org.sonny.filemanager.util;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.ResourceBundle;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class FileProxy {

 /**
  * @param args
  */
 private ResourceBundle properties = null;
 File f = null;
 
 public FileProxy() {}
 
 public static boolean isFolder(String value){
  if(value.indexOf(".") > -1) {
   return false;
  }
  return true;
 }
 public String getValidPatch(String filepath, boolean isNeedNew) {
  loadProperties();
  String root = properties.getString("rootLeft");
  String separate = "/";
  if(filepath.indexOf("\\") > -1) {
   separate = "\\";
   root = properties.getString("rootRight");
  }
  String rpath = root + separate + filepath;
  if(isNeedNew) {
   File file = new File(rpath);
   if(!file.isDirectory()) file.mkdirs();
  }
  return rpath;
 }
 public String getSeparate(String path) {
  String separate = "/";
  if(path.indexOf("\\") > -1) {
   separate = "\\";
  }
  return separate;
 }
 public String getDirRoot() {
  return properties.getString("rootLeft");
 }
 public boolean isExist(String path) {
  String temp = getValidPatch(path, false);
  File file = new File(temp);
  if(!file.isDirectory()) return false;
  return true;
 }
 private void loadProperties() {
  if(properties == null) {
   properties = ResourceBundle.getBundle("cn.bizos.filemanager.resources.FileProperties");
  }
 }
 
}

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Java 项目生成静态页面的代码
Java操作文件、目录
JAVA网站静态化方法
回忆Java 之 文件读写及性能比较总结
java读取TXT文件的方法
多文件合成一个文件工具类
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服