|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.opensha.commons.util.FileUtils
public class FileUtils
Title:FileUtils
Description:Generic functions used in handling text files, such as loading in the text data from a file.
| Field Summary | |
|---|---|
protected static String |
C
Class name used for debug strings |
protected static boolean |
D
boolean that indicates if print out debug statements |
| Constructor Summary | |
|---|---|
FileUtils()
|
|
| Method Summary | |
|---|---|
static File |
createTempDir()
|
static void |
createZipFile(String filesPath)
This function creates a Zip file called "allFiles.zip" for all the files that exist in filesPath. |
static void |
createZipFile(String zipFile,
String dir,
Collection<String> fileNames)
This creates a zip file with the given name from a list of file names. |
static boolean |
deleteRecursive(File f)
|
static void |
downloadURL(String addr,
File outFile)
|
static void |
downloadURL(URL url,
File outFile)
|
static ArrayList<String> |
loadFile(String fileName)
Loads in each line to a text file into an ArrayList ( i.e. |
static ArrayList<String> |
loadFile(String fileName,
boolean skipBlankLines)
Loads in each line to a text file into an ArrayList ( i.e. |
static ArrayList<String> |
loadFile(URL url)
|
static Image |
loadImage(String fileName)
this method accepts the filename and loads the image from the jar file |
static ArrayList<String> |
loadJarFile(String fileName)
load from Jar file |
static Object |
loadObject(String fileName)
|
static Object |
loadObjectFromURL(URL url)
return a object read from the URL |
static ArrayList<String> |
loadStream(InputStream is)
|
static void |
print(PrintJob pjob,
Graphics pg,
String textToPrint)
Prints a Text file |
static void |
save(String fileName,
String dataToSave)
Saves the text to a file on the users machine. |
static void |
saveObjectInFile(String fileName,
Object obj)
save the serialized object into the specified file |
static void |
unzipFile(File zipFile,
File directory)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final String C
protected static final boolean D
| Constructor Detail |
|---|
public FileUtils()
| Method Detail |
|---|
public static ArrayList<String> loadFile(String fileName)
throws FileNotFoundException,
IOException
fileName - File to load in
FileNotFoundException - If the filename doesn't exist
IOException - Unable to read from the file
public static ArrayList<String> loadFile(String fileName,
boolean skipBlankLines)
throws FileNotFoundException,
IOException
fileName - File to load in
FileNotFoundException - If the filename doesn't exist
IOException - Unable to read from the file
public static ArrayList<String> loadFile(URL url)
throws IOException
url - : URL of file to be read
FileNotFoundException
IOException
public static ArrayList<String> loadStream(InputStream is)
throws IOException
is - : input stream of file to be read
FileNotFoundException
IOException
public static ArrayList<String> loadJarFile(String fileName)
throws FileNotFoundException,
IOException
fileName - : File name to be read from Jar file
FileNotFoundException
IOException
public static void saveObjectInFile(String fileName,
Object obj)
throws IOException
fileName - obj -
IOExceptionpublic static Object loadObjectFromURL(URL url)
url -
public static void createZipFile(String zipFile,
String dir,
Collection<String> fileNames)
throws IOException
zipFile - files -
IOExceptionpublic static void createZipFile(String filesPath)
filesPath - String Folder with absolute path in zip file will be created.
This function searches for all the files in the folder "filesPath" and adds
those to a single zip file "allFiles.zip".
public static void unzipFile(File zipFile,
File directory)
throws FileNotFoundException,
IOException
FileNotFoundException
IOExceptionpublic static Object loadObject(String fileName)
fileName - File from where object needs to be read
public static File createTempDir()
throws IOException
IOExceptionpublic static boolean deleteRecursive(File f)
public static Image loadImage(String fileName)
fileName -
public static void downloadURL(String addr,
File outFile)
throws IOException
IOException
public static void downloadURL(URL url,
File outFile)
throws IOException
IOException
public static void print(PrintJob pjob,
Graphics pg,
String textToPrint)
pjob - PrintJob created using getToolkit().getPrintJob(JFrame,String,Properties);pg - GraphicstextToPrint - String
public static void save(String fileName,
String dataToSave)
panel - ComponentdataToSave - String
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||