renameTo为什么用不了?请进!
try{
File pathfile = new File(strRealPathfile);
if (pathfile.exists())
{
String[] strallfile=pathfile.list();
for(int i=0;i<strallfile.length;i++){
if(strallfile[i].equals(strnewfile)){
m_iErrTag=-1;
}
}
pathfile.renameTo(new File (pathfile.getParent (), strnewfile));
m_iErrTag=0;
}else {
m_iErrTag=-1;
}
}catch (SecurityException ex){
ex.printStackTrace();
throw new GeneralException("CommonBean:renameFile() SecurityException:"+ex.getMessage());
}catch (Exception ex) {
ex.printStackTrace();
throw new GeneralException("CommonBean:renameFile() Exception:"+ex.getMessage());
}
一运行就抛出异常CommonBean:renameFile() Exception:null
而我查看了一些资料后,好像不少人都遇到renameTo不好使,是不是和操作系统有关?