public class IO extends Object
Constructor and Description |
---|
IO() |
Modifier and Type | Method and Description |
---|---|
static File |
createTempFile()
Create a temporary file in the generic tmp directory.
|
static File |
createTempFile(Collection tracker)
Create a temporary file and add it to the given
tracker |
static File |
createTempFile(Collection tracker,
String prefix,
String suffix)
Create a temporary file and add it to the given
tracker |
static File |
createTempFile(String prefix,
String suffix)
Create a temporary file in the generic tmp directory.
|
static File |
getAbsoluteFile(String path)
returns an absolute file regarding the cq3 home as cwd.
|
static String |
getAbsolutePath(String path)
returns an absolute path regarding the cq3 home as cwd.
|
static String |
getAppHome()
|
static File |
getAppHomeDirectory()
Deprecated.
use
getCWD() instead. |
static File |
getCanonicalFile(String path)
Normalize a path, converting slashes to platform dependent separators and
removing dots.
|
static File |
getCWD()
Returns the directory of the application home
|
static File |
getTempDir()
Return the temporary directory.
|
static boolean |
isParent(File parent,
File child)
Return a flag indicating whether a file is the parent of another file
|
static String |
readUTF(InputStream in)
Read a UTF encoded string from an input stream.
|
static boolean |
rename(File src,
File dst)
Renames a file to another.
|
static boolean |
rename0(File src,
File dst)
Renames a file to another.
|
static void |
setCQ3Home(File cq3Home)
Deprecated.
use
setCWD(File) instead. |
static void |
setCWD(File cwd)
Initialization of CQ3 home.
|
static void |
setTempDir(File tempDir)
Initialization of temporary directory when used as a separate component.
|
static int |
spool(InputStream in,
byte[] buffer)
Spools data from an
InputStream into an
byte buffer. |
static int |
spool(InputStream in,
OutputStream out)
Spools data from an
InputStream into an
OutputStream . |
static int |
spool(InputStream in,
OutputStream out,
int num)
Spools data from an
InputStream into an
OutputStream . |
static int |
spool(Reader in,
Writer out)
Spools characters from an
Reader into an
Writer . |
static void |
tryClose(InputStream in)
Closes the
InputStream in if not
null and ignores a potential IOException thrown
from closing the stream. |
static void |
tryClose(OutputStream out)
Closes the
OutputStream out if not
null and ignores a potential IOException thrown
from closing the stream. |
static void |
tryClose(Reader reader)
Closes the
Reader out if not
null and ignores a potential IOException thrown
from closing the reader. |
static void |
tryClose(Writer writer)
Closes the
Writer in if not
null and ignores a potential IOException thrown
from closing the writer. |
public static int spool(InputStream in, OutputStream out) throws IOException
InputStream
into an
OutputStream
. Please note, that both, input and output
stream, remain open after the spooling.in
- input streamout
- output streamIOException
- if an I/O error occurspublic static int spool(InputStream in, byte[] buffer) throws IOException
InputStream
into an
byte buffer. either until the buffer is full or the EOF is reached.in
- input streambuffer
- output bufferIOException
- if an I/O error occurspublic static int spool(Reader in, Writer out) throws IOException
Reader
into an
Writer
. Please note, that both, reader and writer remain
open after the spooling.in
- input Readerout
- output WriterIOException
- if an I/O error occurspublic static int spool(InputStream in, OutputStream out, int num) throws IOException
InputStream
into an
OutputStream
. Please note, that both, input and output
stream, remain open after the spooling. This method only transfers
num
bytes or less.in
- input streamout
- output streamIOException
- if an I/O error occurspublic static void tryClose(InputStream in)
InputStream
in
if not
null
and ignores a potential IOException
thrown
from closing the stream.in
- The InputStream
to close. This may be
null
.public static void tryClose(OutputStream out)
OutputStream
out
if not
null
and ignores a potential IOException
thrown
from closing the stream.out
- The OutputStream
to close. This may be
null
.public static void tryClose(Reader reader)
Reader
out
if not
null
and ignores a potential IOException
thrown
from closing the reader.reader
- The Reader
to close. This may be
null
.public static void tryClose(Writer writer)
Writer
in
if not
null
and ignores a potential IOException
thrown
from closing the writer.writer
- The Writer
to close. This may be
null
.public static boolean rename0(File src, File dst)
src
- the source filedst
- the destination filetrue
if the renaming was successful and the file
at leas exists at the new location; false
if the
renaming failed. in this case, the original file still exists.public static String readUTF(InputStream in) throws UTFDataFormatException, IOException
in
- input streamUTFDataFormatException
- if the input stream contains an invalid combination of bytesIOException
- if an I/O error occurspublic static void setCWD(File cwd)
setTempDir(File)
must be called before methods inside IO
may be used.cwd
- directory to use as current work directorypublic static void setCQ3Home(File cq3Home)
setCWD(File)
instead.setTempDir(File)
must be called before methods inside IO
may be used.cq3Home
- directory to use as CQ3 home.public static void setTempDir(File tempDir)
tempDir
- temporary directory to usepublic static File getTempDir()
public static String getAppHome()
public static File getAppHomeDirectory()
getCWD()
instead.public static File getCWD()
public static File getCanonicalFile(String path)
null
if the path cannot be
normalizedpublic static boolean isParent(File parent, File child)
parent
- parent filechild
- child filetrue
if parent is parent of child, otherwise
false
public static File createTempFile(Collection tracker) throws IOException
tracker
tracker
- collection that is use to record the generated temp file.IOException
- if an I/O error occurspublic static File createTempFile(Collection tracker, String prefix, String suffix) throws IOException
tracker
tracker
- collection that is use to record the generated temp file.prefix
- the prefix for the temporary filesuffix
- the suffix for the temporary fileIOException
- if an I/O error occurspublic static File createTempFile() throws IOException
IOException
- if an I/O error occurspublic static File createTempFile(String prefix, String suffix) throws IOException
prefix
- the prefix for the filesuffix
- the suffix for the fileIllegalArgumentException
- If the prefix argument contains fewer than three charactersIOException
- If a file could not be createdpublic static String getAbsolutePath(String path)
path
already is absolute, this string itself is returned.path
- the relative pathpublic static File getAbsoluteFile(String path)
path
- the relative pathpublic static boolean rename(File src, File dst)
src
- the source filedst
- the destination filetrue
if the renaming was successful and the file
at leas exists at the new location; false
if the
renaming failed. in this case, the original file still exists."Copyright © 2006 - 2015 Adobe Systems Incorporated. All Rights Reserved"