|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
utils.FileManager
public class FileManager
Servlet implementation class for Servlet: FileManager
| Nested Class Summary | |
|---|---|
class |
FileManager.NodeInfo
An object to hold information for a node. |
class |
FileManager.NodeInfoComparator
Comparator that compares NodeInfo objects. |
| Constructor Summary | |
|---|---|
FileManager()
|
|
| Method Summary | |
|---|---|
void |
copy(File src,
File dest)
Copies the given File src to the given File dest. |
protected void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
protected void |
doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
File |
generateUniqueFile(File parent,
String ext)
Given a parent directory File and a file extension String
generates and returns a File with a unique filename. |
String |
getFileExtension(String filename)
Given a String filename, returns the String extension. |
String |
getFileText(File file)
Given a File, reads the text from the file as a String
and returns the string. |
String |
getUniqueFileNamePrefix(File parent)
Get a file name prefix that has not been used yet |
void |
writeFile(File file,
String data,
boolean overwrite)
Given a File the file to write to and the String data to write
to that file and a boolean overwrite, indicating whether the file should be
overwritten if it exists, writes the data to the file specified. |
void |
writeFile(String path,
String data,
boolean overwrite)
Given a String path to the file to write to and the String data
to write to that file and a boolean overwrite, indicating whether the file
should be overwritten if it exists, writes the data to the file specified. |
| Methods inherited from class javax.servlet.http.HttpServlet |
|---|
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service |
| Methods inherited from class javax.servlet.GenericServlet |
|---|
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface javax.servlet.Servlet |
|---|
destroy, getServletConfig, getServletInfo, init, service |
| Constructor Detail |
|---|
public FileManager()
| Method Detail |
|---|
protected void doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws javax.servlet.ServletException,
IOException
doGet in class javax.servlet.http.HttpServletjavax.servlet.ServletException
IOException
protected void doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
throws javax.servlet.ServletException,
IOException
doPost in class javax.servlet.http.HttpServletjavax.servlet.ServletException
IOException
public void writeFile(File file,
String data,
boolean overwrite)
throws IOException
File the file to write to and the String data to write
to that file and a boolean overwrite, indicating whether the file should be
overwritten if it exists, writes the data to the file specified.
File - fileString - databoolean - overwrite
IOException
IOException
public void writeFile(String path,
String data,
boolean overwrite)
throws IOException
String path to the file to write to and the String data
to write to that file and a boolean overwrite, indicating whether the file
should be overwritten if it exists, writes the data to the file specified.
File - fileString - databoolean - overwrite
IOException
IOException
public String getFileText(File file)
throws IOException
File, reads the text from the file as a String
and returns the string.
File - file
String text
IOException
IOExceptionpublic String getFileExtension(String filename)
String filename, returns the String extension.
If the filename has no extension, returns the filename.
filename -
public File generateUniqueFile(File parent,
String ext)
File and a file extension String
generates and returns a File with a unique filename.
parent - ext -
public String getUniqueFileNamePrefix(File parent)
parent - the directory where we want to search files
public void copy(File src,
File dest)
throws FileNotFoundException,
IOException
File src to the given File dest. If they
are directories, recursively copies the contents of the directories.
File - srcFile - dest
FileNotFoundException
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||