Results 1 to 2 of 2
  1. #1
    ralph is offline Member
    Join Date
    Nov 2012
    Posts
    36
    Rep Power
    0

    Default How to scan C:\ drive equivalent on Mac/Linux

    I have written code that scans the entire C:\ drive and outputs the path to certain files, but how would I go about doing this for Mac (Having barely used a Mac before I'm not sure how different the folder structures are). Is it as simple as replacing "C:/" with "Macintosh HD" or "/" ?

    Java Code:
    public static void main(String[] args)
        {
            String initDir = "C:/";
            File file = new File( initDir );
            scanForJVM( file );
        }
    
    public static void scanForJVM( File file )
        {
            if( file.isDirectory() )
            {
                if( file.getPath().toString().endsWith( "cfusion.war" ) )
                {
                    try
                    {
                        File file2 = file.getParentFile();
    					System.out.println(file2.toString());
                    }
                    catch( Exception e )
                    {
    
                    }
                }
    
                File[] listOfFiles = file.listFiles();
                if( listOfFiles != null )
                {
                    for( int i = 0; i < listOfFiles.length; i++ )
                        scanForJVM( listOfFiles[i] );
                }
            }
        }
    Thank you again for any help!

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,411
    Rep Power
    5

    Default Re: How to scan C:\ drive equivalent on Mac/Linux

    Did you read the File API? It discusses the property file.separator. It also discusses the situation you are talking about.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

Similar Threads

  1. Replies: 6
    Last Post: 04-06-2012, 08:29 AM
  2. Replies: 0
    Last Post: 01-04-2011, 07:44 PM
  3. Java equivalent of Linux 'find' function
    By porchrat in forum New To Java
    Replies: 5
    Last Post: 08-25-2010, 11:31 AM
  4. Best way to format a drive/thumb drive in java...
    By vandyke in forum Advanced Java
    Replies: 1
    Last Post: 12-09-2009, 01:32 AM
  5. Replies: 6
    Last Post: 04-08-2009, 04:05 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
  •