i am getting this problem while running my program. Please help. The error report points at line no 17.
import java.io.*;
public class Rename{
public static void main(String args[]){
File dir=new File("C:\\irla_ pdf\\eme\\MPS_P dfs_10_2011"); //enter the location where mps pdf files are kept
String [] fname=dir.list( );
if(fname==null)
System.out.prin tln("no files");
else{
for(int i=0;i<dir.lengt h();i++){
File pdffilename=new File("C:\\irla_ pdf\\eme\\MPS_P dfs_10_2011\\"+ fname[i]); //enter the location where mps pdf files are kept
//System.out.prin tln("existing name "+pdffilena me);
String newname=fname[i].substring(11,1 9)+".pdf";
File newfilename=new File("c:\\irla_ pdf\\eme\\pdf10 11\\"+newname);//enter the location where renamed pdf files are to be kept
//System.out.prin tln("new filename "+newfilena me);
if(pdffilename. renameTo(new File("c:\\irla_ pdf\\eme\\pdf10 11\\"+newname)) ){
//System.out.prin tln("renamed");
}
else
System.out.prin tln("error");
//System.out.prin tln(fname[i]);
//System.out.prin tln(newname);
}
}
}
}
import java.io.*;
public class Rename{
public static void main(String args[]){
File dir=new File("C:\\irla_ pdf\\eme\\MPS_P dfs_10_2011"); //enter the location where mps pdf files are kept
String [] fname=dir.list( );
if(fname==null)
System.out.prin tln("no files");
else{
for(int i=0;i<dir.lengt h();i++){
File pdffilename=new File("C:\\irla_ pdf\\eme\\MPS_P dfs_10_2011\\"+ fname[i]); //enter the location where mps pdf files are kept
//System.out.prin tln("existing name "+pdffilena me);
String newname=fname[i].substring(11,1 9)+".pdf";
File newfilename=new File("c:\\irla_ pdf\\eme\\pdf10 11\\"+newname);//enter the location where renamed pdf files are to be kept
//System.out.prin tln("new filename "+newfilena me);
if(pdffilename. renameTo(new File("c:\\irla_ pdf\\eme\\pdf10 11\\"+newname)) ){
//System.out.prin tln("renamed");
}
else
System.out.prin tln("error");
//System.out.prin tln(fname[i]);
//System.out.prin tln(newname);
}
}
}
}
Comment