igpp.util
Class Listing

java.lang.Object
  extended by igpp.util.Listing

public class Listing
extends Object

Simple file and directory listing utility methods.

Version:
1.00 2009
Author:
Todd King

Constructor Summary
Listing()
           
 
Method Summary
static boolean exists(File root, String pathName)
          Determine if a file or folder exists at the location of a File object.
static File getFile(File root, String pathName)
          Get the File object file or folder with a given name located at the location of a File object.
static File[] getFileList(File root)
          Get the list of files located at the location specified with File object.
static File[] getFileList(File root, String pattern)
          Get the list of files located at the location specified with File object.
static File[] getFileList(String pathName)
          Get the list of files at the current path.
static File[] getFileList(String pathName, String pattern)
          Get the list of files at the current path that match a particular pattern.
static File[] getFileListByExtension(File root, String extension)
          Get the list of files at the current path that have a particular filename extension.
static File[] getFileListByExtension(String pathName, String extension)
          Get the list of files at the current path that have a particular filename extension.
static File getFirstFile(File root)
          Get the first file in the sorted file list at the location specified with File object.
static File[] getFolderList(File root)
          Get the list of folders located at the location specified with File object.
static File[] getFolderList(String pathName)
          Get the list of folders at the current path.
static File getLastFile(File root)
          Get the last file in the sorted file list at the location specified with File object.
static File getMostRecentFile(File root)
          Get the most recent file placed in at the location specified with File object.
static BufferedReader getReader(File root, String pathName)
          Obtain a BufferedReader for a file at the location of a File object.
static BufferedReader getReader(String pathName)
          Obtain a BufferedReader for pathname string.
static File[] getSortedList(File[] list, int sortOn)
          Sort an array of File items based on an attribute of each file.
static File[] getSortedList(File[] list, int sortOn, int direction)
          Sort an array of File items based on an attribute of each file.
static void main(String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Listing

public Listing()
Method Detail

main

public static void main(String[] args)

getFolderList

public static File[] getFolderList(String pathName)
Get the list of folders at the current path.

Returns:
Array of File items for each folder, null if no folders are present.

getFolderList

public static File[] getFolderList(File root)
Get the list of folders located at the location specified with File object.

Returns:
Array of File items for each folder, null if no folders are present.

getFileList

public static File[] getFileList(String pathName)
Get the list of files at the current path.

Returns:
Array of File items for each file, null if no files are present.

getFileListByExtension

public static File[] getFileListByExtension(String pathName,
                                            String extension)
Get the list of files at the current path that have a particular filename extension. The comparision is case insensitive.

Returns:
Array of File items for each file, null if no files are present.

getFileListByExtension

public static File[] getFileListByExtension(File root,
                                            String extension)
Get the list of files at the current path that have a particular filename extension. The comparision is case insensitive.

Returns:
Array of File items for each file, null if no files are present.

getFileList

public static File[] getFileList(String pathName,
                                 String pattern)
Get the list of files at the current path that match a particular pattern. The pattern is expressed using regular expressions.

Returns:
Array of File items for each file, null if no files are present.

getFileList

public static File[] getFileList(File root,
                                 String pattern)
Get the list of files located at the location specified with File object.

Returns:
Array of File items for each file, null if no files are present.

getFileList

public static File[] getFileList(File root)
Get the list of files located at the location specified with File object.

Returns:
Array of File items for each file, null if no files are present.

getMostRecentFile

public static File getMostRecentFile(File root)
Get the most recent file placed in at the location specified with File object.

Returns:
Array of File items for each file, null if no files are present.

getFirstFile

public static File getFirstFile(File root)
Get the first file in the sorted file list at the location specified with File object.

Returns:
Array of File items for each file, null if no files are present.

getLastFile

public static File getLastFile(File root)
Get the last file in the sorted file list at the location specified with File object.

Returns:
Array of File items for each file, null if no files are present.

getFile

public static File getFile(File root,
                           String pathName)
Get the File object file or folder with a given name located at the location of a File object.

Returns:
File pointing to the desired file, otherwise null.

exists

public static boolean exists(File root,
                             String pathName)
Determine if a file or folder exists at the location of a File object.

Returns:
true if

getSortedList

public static File[] getSortedList(File[] list,
                                   int sortOn,
                                   int direction)
Sort an array of File items based on an attribute of each file. FileComparator for a list of allowed values for sortOn and direction.

Returns:
Array of File items for each file, null if no folders are present.

getSortedList

public static File[] getSortedList(File[] list,
                                   int sortOn)
Sort an array of File items based on an attribute of each file. List is sorted in ascending order. FileComparator for a list of allowed values for sortOn.

Returns:
Array of File items for each file, null if no folders are present.

getReader

public static BufferedReader getReader(File root,
                                       String pathName)
Obtain a BufferedReader for a file at the location of a File object.

Returns:
A new instance of a BufferedReader if file exists, otherwise null.

getReader

public static BufferedReader getReader(String pathName)
Obtain a BufferedReader for pathname string.

Returns:
A new instance of a BufferedReader if file exists, otherwise null.


Copyright © 2008-2009 Regents University of California. All Rights Reserved.