john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

FileSystem FileBrowser INCOMPLETE

//2012-02-26
//requires CommandLineParams.java
import java.io.File;

class FileBrowser
{
    private FileSystem fs;
    private String currentListing[];
    private File roots[];
    private File firstroot;

    FileBrowser()
    {
        fs = new FileSystem();
        roots = java.io.File.listRoots();
        if( roots != null )
        {
            File f = roots[0];
            currentListing = f.list();
        }
    }

  public static void main( String args[] )
  {

    FileBrowser fb = new FileBrowser();
    fb.displayCurrentListing( fb.currentListing );
    fb.displayFileSystemToString();


    /*

        fb.displayFileArrayElements( fb.contents );

        File f = new File( "/" );
        String listing[] = fb.getContents( f );
        int i = 0;
        for( i = 0; i < listing.length; i++ )
        {
            System.out.println( listing[i] );
        }
      */
  }

  private void displayFileSystemToString()
  {
    String fsString = fs.toString();
    System.out.println( fsString );
  }

  private String[] getContents( File current )
  {
    String contents[] = null;
    try
     {  contents = current.list( );
     }
     catch( Exception e )
     {  e.printStackTrace();
     }
     return contents;
  }


  private void display( String args[] )
  {
    CommandLineParameter cmdlineparams = new CommandLineParameter( 1 , "version 0.1: java -jar FileBrowse.jar filename" );
    cmdlineparams.isValid( args , System.out );

        File f = new File( args[0] );
  }


  private void displayCurrentListing( String a[] )
  {
    if( a != null )
    {
        for( int i = 0; i < a.length ; i++ )
        {   System.out.println( a[i] );
        }
    }
  }

} //end class

  • « Perl pass a function as a parameter
  • Perl netstat split string array »

Published

Feb 27, 2012

Category

java-classes

~137 words

Tags

  • classes 92
  • filebrowser 2
  • filesystem 6
  • incomplete 22
  • java 252