Results 1 to 3 of 3
  1. #1
    hnj81 is offline Member
    Join Date
    Feb 2009
    Posts
    1
    Rep Power
    0

    Question How to read pdf files from the folder using java?

    Hello All:

    I have following code ... which read all the files in the folder ... I would like to read only pdf files ... I am new to Java please help me...

    String readSourceLocation(){

    File myFolder = new File(m_config.getValue("SOURCE_LOCATION"));//"C:\\myDocuments");
    File allMyFolderObjects[] = myFolder.listFiles();

    String src = allMyFolderObjects[0].toString();

    System.out.println("~~~~~~~~~~~ Source : " + src);
    return src;
    }

  2. #2
    jurka is offline Member
    Join Date
    Jul 2008
    Posts
    67
    Rep Power
    0

    Default

    If i understood you correctly then you wanted something like this. But if you wanted to read also pdf content then there is great tool for that iText.

    Java Code:
    import java.io.File;
    
    
    public class ByTypeSearch {
    
    	public static void main(String[] args) {
    		File location = new File("c:\\");
    		String type = "db"; // replace what ever type of file you need to search
    		
    		if (location.isDirectory() && location != null) {
    			for (File f : location.listFiles()) {
    				if (f.isFile() && f.getName().endsWith(type)) {
    					System.out.println(f.getName() + " length " + f.length());
    				}
    			}
    		}
    
    	}
    
    }

  3. #3
    mosesalph is offline Member
    Join Date
    Feb 2009
    Posts
    4
    Rep Power
    0

Similar Threads

  1. How To Place Three Files In A Folder
    By ramesh.8189 in forum AWT / Swing
    Replies: 4
    Last Post: 02-12-2009, 08:59 AM
  2. Placing Files In Folder
    By ramesh.8189 in forum New To Java
    Replies: 0
    Last Post: 02-06-2009, 01:36 PM
  3. Replies: 0
    Last Post: 10-06-2008, 04:42 PM
  4. Need to find large files and folder on the PC. What app needed?
    By Cleaner007 in forum Reviews / Advertising
    Replies: 1
    Last Post: 09-30-2008, 08:06 PM
  5. iteration on huge amount of files in a folder
    By tshaked in forum Advanced Java
    Replies: 1
    Last Post: 08-07-2007, 08:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •