|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object | +--ru.novosoft.dc.core.IOService
The class contains miscellaneous static I/O service methods.
| Method Summary | |
static java.lang.String |
addFileProtocol(java.lang.String path)
Convert a path to the canonical form, add the "file:" protocol at the beginning of path, and return the result. |
static java.lang.String |
appendExtension(java.lang.String path,
java.lang.String extension)
Append the specified extension to the path, if the path just not has this extension yet, and return the result. |
static void |
closeOut(java.io.OutputStream out)
Close the output stream and catch the IOException. |
static boolean |
createDirectory(java.lang.String path)
Try to create a directory with the specified path and return true if the directory already exists or the creation was successful. |
static java.lang.String |
createPath(java.lang.String path,
java.lang.String extension)
Create a new path by replacing the extension of the specified path to the specified extension. |
static java.lang.String |
findFileInResources(java.lang.String path)
Try to find a file in resources (in path list specified in the Java classpath variable) and return the canonical path to it or null if search fails. |
static java.lang.String |
findHomePath(java.lang.String propertyName)
Find a home path using a value of system property with the specified propertyName name and return it. |
static java.lang.String[] |
getFileList(java.lang.Class cls,
java.lang.String homePath,
java.lang.String relPath)
Return an array of strings naming the files and directories found in resources. |
static java.lang.String |
getFilePath(java.lang.String homePath,
java.lang.String relPath,
java.lang.String path)
Prepare a path to file. |
static java.io.InputStream |
getResourceAsStream(java.lang.Class cls,
java.lang.String homePath,
java.lang.String relPath,
java.lang.String path)
Try to open an input stream at the resource. |
static boolean |
hasFileProtocol(java.lang.String path)
Test a path to start with file protocol. |
static java.util.Properties |
loadPropertiesFrom(java.io.File file)
Try to load properties from a specified file. |
static java.util.Properties |
loadPropertiesFrom(java.io.InputStream stream)
Try to load properties from a specified stream. |
static java.util.Properties |
loadPropertiesFrom(java.lang.String path)
Try to load properties from file at the specified path. |
static java.io.OutputStream |
openForWriting(java.lang.String path)
Try to open a file in the specified path for writing with creation of all parent directories if necessary. |
static java.lang.String |
removeFileProtocol(java.lang.String path)
Test a path to start with the "file:" protocol, remove it from the path name, and convert the path to canonical form. |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
| Method Detail |
public static java.lang.String createPath(java.lang.String path,
java.lang.String extension)
path - a path to replace an extensionextension - a new extension starting from the dot (e.g., ".log")
public static java.lang.String appendExtension(java.lang.String path,
java.lang.String extension)
path - a path to append an extension toextension - an extension to be appended (e.g., ".opt")public static java.lang.String findFileInResources(java.lang.String path)
public static java.lang.String[] getFileList(java.lang.Class cls,
java.lang.String homePath,
java.lang.String relPath)
relPath starts with "file:" protocol,
it should be a directory. The list of all files of the directory is
returned;
cls object
and select all files stored in the relPath directory
relative to the package of cls;
relPath directory relative to the
homePath and add all its files to the list prepared at
the previous step;
cls==null, the second step is skipped.
If homePath equals null or empty string, the last step
is skipped. Return null if no directory for search found.
public static java.io.InputStream getResourceAsStream(java.lang.Class cls,
java.lang.String homePath,
java.lang.String relPath,
java.lang.String path)
relPath with path and
delimit them with slash symbol if necessary;
path equals null or empty string, the first three steps
are omitted. If homePath equals null or empty string,
the fifth step is skipped.cls - a base class to get resource athomePath - an absolute path to a home directoryrelPath - a relative subdirectory path (can start with "file:"
protocol)path - a path to the resource to be openned (can start with
"file:" protocol)
public static java.lang.String getFilePath(java.lang.String homePath,
java.lang.String relPath,
java.lang.String path)
relPath with path and
delimit them with slash symbol if necessary;
path equals null or empty string, the first three steps
are omitted. If homePath equals null or empty string,
the fifth step returns null.homePath - an absolute path to a home directoryrelPath - a relative subdirectory path (can start with "file:"
protocol)path - a path to the resource to be openned (can start with
"file:" protocol)public static java.lang.String findHomePath(java.lang.String propertyName)
propertyName name and return it. If the property is undefined,
the first element of the CLASSPATH list is used as the home path.public static final boolean hasFileProtocol(java.lang.String path)
public static java.lang.String addFileProtocol(java.lang.String path)
public static java.lang.String removeFileProtocol(java.lang.String path)
public static boolean createDirectory(java.lang.String path)
public static final java.util.Properties loadPropertiesFrom(java.lang.String path)
public static java.util.Properties loadPropertiesFrom(java.io.File file)
public static java.util.Properties loadPropertiesFrom(java.io.InputStream stream)
public static java.io.OutputStream openForWriting(java.lang.String path)
throws java.io.IOException
public static final void closeOut(java.io.OutputStream out)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||