Results 1 to 3 of 3

Thread: File Search

  1. #1
    Juggler's Avatar
    Juggler is offline Member
    Join Date
    Jul 2008
    Location
    Chennai,India
    Posts
    16
    Rep Power
    0

    Unhappy File Search

    hello friends
    Idevelop the project using file concept please any one help me to how to search the file in windows OS

  2. #2
    Mir
    Mir is offline Senior Member
    Join Date
    Mar 2008
    Posts
    447
    Rep Power
    7

    Default

    Quote Originally Posted by Juggler View Post
    hello friends
    Idevelop the project using file concept please any one help me to how to search the file in windows OS
    if you search with the name then this code help you fiend the file path..I am not sure it help you or not..
    Java Code:
    	import java.io.*;
    
    	public class FileNameReferToSameFile{
    		public static void main(String args[]){
    			File file1 = new File("./file.txt");
    		    File file2 = new File("file.txt");
    			System.out.println("Actual fileName1 = " + file1 + "\n");
    	        System.out.println("Actual fileName2 = " + file2 + "\n");
        
    			// It returns false if Filename paths are not equal 
    		    boolean b = file1.equals(file2);      
    			System.out.println("It checks whether the file name paths are equal or not"  +  b);
    
    		    // Normalize the paths
    		    try {
    		        file1 = file1.getCanonicalFile();					// c:\tapan\filename
    				file2 = file2.getCanonicalFile();					// c:\tapan\filename
    				System.out.println("Actual path of filName1 = " + file1 + "\n");
    		        System.out.println("Actual path of fileName2 = " + file2 + "\n");
    		    } catch (IOException e) {
    				System.out.println("IOException is "+ e);
    			}
        
    		    // It returns true if Filename paths are  equal
    		    b = file1.equals(file2);              
    			System.out.println("the file name are now equal"  +   b);
    			System.out.println("Actual path of fileName1 = " + file1 + "\n");
    	        System.out.println("Actual path of fileName2 = " + file2 + "\n");
    		}
    	}

  3. #3
    Juggler's Avatar
    Juggler is offline Member
    Join Date
    Jul 2008
    Location
    Chennai,India
    Posts
    16
    Rep Power
    0

Similar Threads

  1. Search in text file
    By mark-mlt in forum New To Java
    Replies: 6
    Last Post: 04-03-2009, 04:33 PM
  2. Replies: 0
    Last Post: 04-04-2008, 09:36 AM
  3. Search
    By Gilgamesh in forum New To Java
    Replies: 5
    Last Post: 11-26-2007, 03:45 AM
  4. Web Search
    By Marcus in forum Enterprise JavaBeans (EJB)
    Replies: 2
    Last Post: 07-02-2007, 06:51 AM
  5. Replies: 1
    Last Post: 06-06-2007, 04:20 AM

Posting Permissions

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