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");
}
}
}
聯(lián)系客服