File Access Error

Help
Angelbeach
2013-05-15
2013-09-10
  • Angelbeach

    Angelbeach - 2013-05-15

    I have tried searching the forums but I cannot find an answer to my file access problem. My code is:

    ~~~~~~~
    import org.pdfclown.documents.Document;
    import org.pdfclown.documents.Page;
    import org.pdfclown.files.File;
    import org.pdfclown.documents.PageFormat;
    import org.pdfclown.objects.PdfDictionary;
    import org.pdfclown.objects.PdfObjectWrapper;
    import org.pdfclown.tools.TextExtractor;

    public class readPDF {

    public static void main(String[] args) {
    
        String filePath = "C:\\Java\\Docs\\testPDF.pdf";
        System.out.println("Let's start processing PDF Files");
    
        // 1. Open the PDF file!
        File pdfFile;
        try
        {
            pdfFile = new File(filePath);
            System.out.println("File is there.");
        }
        catch(Exception e)
        {
            throw new RuntimeException(filePath + " file access error.",e);
        }
    
    }
    

    }
    ~~~~~~

    When running this the code cannot find the file, but if I replace "File pdfFile;" and "pdfFile = new File(filePath);" with "java.io.File pdfFile;" and "pdfFile = new java.io.File(filePath);" repectively the file can be accessed. Can anyone help me or point me to a resource to show me how to access the file without having to use the java.io.class designation? From what I have read the PDFClown File class should not have a problem with this, correct?

    Thanks!

     
  • trevor

    trevor - 2013-09-10

    change:
    File pdfFile;
    to:
    org.pdfclown.files.File pdfFile;

    and change:
    pdfFile = new File(filePath);
    to:
    pdfFile = new org.pdfclown.files.File(filePath);

    hope that works for you
    cheers/trevor

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks