完成书签的导出和自动备份到百度云
This commit is contained in:
@ -11,7 +11,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 文件处理工具类
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class FileUtils extends org.apache.commons.io.FileUtils
|
||||
@ -20,7 +20,7 @@ public class FileUtils extends org.apache.commons.io.FileUtils
|
||||
|
||||
/**
|
||||
* 输出指定文件的byte数组
|
||||
*
|
||||
*
|
||||
* @param filePath 文件路径
|
||||
* @param os 输出流
|
||||
* @return
|
||||
@ -76,7 +76,7 @@ public class FileUtils extends org.apache.commons.io.FileUtils
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
*
|
||||
*
|
||||
* @param filePath 文件
|
||||
* @return
|
||||
*/
|
||||
@ -93,9 +93,31 @@ public class FileUtils extends org.apache.commons.io.FileUtils
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归删除目录下的所有文件及子目录下所有文件
|
||||
* @param dir 将要删除的文件目录
|
||||
* @return boolean Returns "true" if all deletions were successful.
|
||||
* If a deletion fails, the method stops attempting to
|
||||
* delete and returns "false".
|
||||
*/
|
||||
public static boolean deleteDir(File dir) {
|
||||
if (dir.isDirectory()) {
|
||||
String[] children = dir.list();
|
||||
//递归删除目录中的子目录下
|
||||
for (int i=0; i<children.length; i++) {
|
||||
boolean success = deleteDir(new File(dir, children[i]));
|
||||
if (!success) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 目录此时为空,可以删除
|
||||
return dir.delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件名称验证
|
||||
*
|
||||
*
|
||||
* @param filename 文件名称
|
||||
* @return true 正常 false 非法
|
||||
*/
|
||||
@ -106,7 +128,7 @@ public class FileUtils extends org.apache.commons.io.FileUtils
|
||||
|
||||
/**
|
||||
* 下载文件名重新编码
|
||||
*
|
||||
*
|
||||
* @param request 请求对象
|
||||
* @param fileName 文件名
|
||||
* @return 编码后的文件名
|
||||
|
@ -2,11 +2,15 @@ package com.ruoyi.common.utils.file;
|
||||
|
||||
/**
|
||||
* 媒体类型工具类
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class MimeTypeUtils
|
||||
{
|
||||
public static final String HTML = ".html";
|
||||
|
||||
public static final String ZIP = ".zip";
|
||||
|
||||
public static final String IMAGE_PNG = "image/png";
|
||||
|
||||
public static final String IMAGE_JPG = "image/jpg";
|
||||
@ -16,7 +20,7 @@ public class MimeTypeUtils
|
||||
public static final String IMAGE_BMP = "image/bmp";
|
||||
|
||||
public static final String IMAGE_GIF = "image/gif";
|
||||
|
||||
|
||||
public static final String[] IMAGE_EXTENSION = { "bmp", "gif", "jpg", "jpeg", "png" };
|
||||
|
||||
public static final String[] FLASH_EXTENSION = { "swf", "flv" };
|
||||
|
@ -1,15 +1,10 @@
|
||||
package com.ruoyi.common.utils.http;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.ConnectException;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLContext;
|
||||
@ -22,7 +17,7 @@ import com.ruoyi.common.constant.Constants;
|
||||
|
||||
/**
|
||||
* 通用http发送方法
|
||||
*
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
public class HttpUtils
|
||||
@ -259,4 +254,34 @@ public class HttpUtils
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 格式化路径参数 可选参数
|
||||
*
|
||||
* @param uri uri
|
||||
* @param map map
|
||||
* @return initUriPathParams
|
||||
* @throws UnsupportedEncodingException 异常
|
||||
*/
|
||||
public static String initUriPathParams(String uri, Map<String, String> map) throws UnsupportedEncodingException {
|
||||
String key;
|
||||
String value;
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(uri);
|
||||
builder.append("?");
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
key = entry.getKey();
|
||||
value = entry.getValue();
|
||||
String tmpKv;
|
||||
tmpKv = String.format(Locale.ROOT, "%s=%s&", URLEncoder.encode(key, "UTF-8"),
|
||||
URLEncoder.encode(value, "UTF-8"));
|
||||
builder.append(tmpKv);
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user