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 "/" ?
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!
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