0

I have a small class that should allow me to rename and move some files and directories. Compilation gives me no syntax errors but when trying to execute, it freezes and I an error is displayed : Error: ';' expected - without specifying a line.

My code is:

class Move{ 
public void Move(){}
public static void moveDir(String Name){
    try{
        File Template_1 = new File("Template_1.pdf");
        File NamePDF = new File(Name+"PDF.pdf");
        File NameFile = new File(Name);
        org.apache.commons.io.FileUtils.forceMkdir(NamePDF);
        File usr = new File(org.apache.commons.io.FileUtils.getUserDirectoryPath()+File.separator+"Pdf_Auswertung");
        org.apache.commons.io.FileUtils.waitFor(Template_1,3);
        org.apache.commons.io.FileUtils.copyFile(Template_1, NamePDF);
        org.apache.commons.io.FileUtils.moveFileToDirectory(NamePDF, NameFile, true); 
        org.apache.commons.io.FileUtils.forceDelete(Template_1);
        org.apache.commons.io.FileUtils.moveDirectoryToDirectory(NameFile, usr, true);
    } catch (IOException e){}
}
}

And also I coudn't figure out where a semicolon is missing or a line should be ending. Any ideas?

M. St.
  • 63
  • 6

1 Answers1

0

On this line:

org.apache.commons.io.FileUtils.forceMkdir(NamePDF);

You are trying to create a directory using a pdf filename. You should specify where are you creating the directory.

If the NamePDF File exists you could do this to get the parent directory:

NamePDF.getParentFile();
Cako
  • 396
  • 3
  • 15