文件复制:
public static boolean CopyFile(byte[] byt ,String filename,String path) throws IOException {
FileOutputStream fos = null;
File dir = new File(path);
try{
if (!dir.exists()) {
dir.mkdirs();
}
if(new File(path+filename).exists()){
new File(path+filename).delete();
}
fos = new FileOutputStream(new File(path+filename));
fos.write(byt);
fos.flush();
return true;
}catch(IOException e){
e.printStackTrace();
}finally{
if(fos !=null){
fos.flush();
fos.close();
}
}
return true;
}
url特殊字符过滤
public static String replaceHtml(Object o){
if(o == null){
return "";
}else{
final String filterPattern="[\\[`~!@#$%^*()+|{}';',<>~!@#¥%……&*()——+|{}【】‘;:”“’。,、?\\]]";
String inputStr =String.valueOf(o).replaceAll(filterPattern," ");
inputStr=inputStr.replaceAll("location", "");
inputStr=inputStr.replaceAll("window", "");
return inputStr;
}
}