/**
* 根据文件名取文件【含相对路径和绝对路径处理】
* @param inputfile
* @return
*/
public static File getFileByFileName(String inputfile){
File inFile = null;
String separator = System.getProperty("file.separator");
if("\\".equals(separator)){
//windows版本
if(inputfile.indexOf(":") > 0){
inFile = new File(inputfile);
}else{
File file = new File("");
String currFilePath = file.getAbsolutePath()+"\\";
inFile = new File(currFilePath+inputfile);
}
}else{
//unix版本
if(inputfile.startsWith("/")){
inFile = new File(inputfile);
}else{
File file = new File("");
String currFilePath = file.getAbsolutePath()+"/";
inFile = new File(currFilePath+inputfile);
}
}
System.out.print("\n currFilePath: " + inFile.getAbsolutePath());
return inFile;
}
* 根据文件名取文件【含相对路径和绝对路径处理】
* @param inputfile
* @return
*/
public static File getFileByFileName(String inputfile){
File inFile = null;
String separator = System.getProperty("file.separator");
if("\\".equals(separator)){
//windows版本
if(inputfile.indexOf(":") > 0){
inFile = new File(inputfile);
}else{
File file = new File("");
String currFilePath = file.getAbsolutePath()+"\\";
inFile = new File(currFilePath+inputfile);
}
}else{
//unix版本
if(inputfile.startsWith("/")){
inFile = new File(inputfile);
}else{
File file = new File("");
String currFilePath = file.getAbsolutePath()+"/";
inFile = new File(currFilePath+inputfile);
}
}
System.out.print("\n currFilePath: " + inFile.getAbsolutePath());
return inFile;
}