public class IO
extends java.lang.Object
Constructor and Description |
---|
IO() |
Modifier and Type | Method and Description |
---|---|
static java.io.File |
createTempFile()
Create a temporary file in the generic tmp directory.
|
static java.io.File |
createTempFile(java.util.Collection tracker)
Create a temporary file and add it to the given
tracker |
static java.io.File |
createTempFile(java.util.Collection tracker,
java.lang.String prefix,
java.lang.String suffix)
Create a temporary file and add it to the given
tracker |
static java.io.File |
createTempFile(java.lang.String prefix,
java.lang.String suffix)
Create a temporary file in the generic tmp directory.
|
static java.io.File |
getAbsoluteFile(java.lang.String path)
returns an absolute file regarding the cq3 home as cwd.
|
static java.lang.String |
getAbsolutePath(java.lang.String path)
returns an absolute path regarding the cq3 home as cwd.
|
static java.lang.String |
getAppHome()
Deprecated.
use
getCWD() .getPath() instead. |
static java.io.File |
getAppHomeDirectory()
Deprecated.
use
getCWD() instead. |
static java.io.File |
getCanonicalFile(java.lang.String path)
Normalize a path, converting slashes to platform dependent separators and
removing dots.
|
static java.io.File |
getCWD()
Returns the directory of the application home
|
static java.io.File |
getTempDir()
Return the temporary directory.
|
static boolean |
isParent(java.io.File parent,
java.io.File child)
Return a flag indicating whether a file is the parent of another file
|
static java.lang.String |
readUTF(java.io.InputStream in)
Read a UTF encoded string from an input stream.
|
static boolean |
rename(java.io.File src,
java.io.File dst)
Renames a file to another.
|
static boolean |
rename0(java.io.File src,
java.io.File dst)
Renames a file to another.
|
static void |
setCQ3Home(java.io.File cq3Home)
Deprecated.
use
setCWD(File) instead. |
static void |
setCWD(java.io.File cwd)
Initialization of CQ3 home.
|
static void |
setTempDir(java.io.File tempDir)
Initialization of temporary directory when used as a separate component.
|
static int |
spool(java.io.InputStream in,
byte[] buffer)
Spools data from an
InputStream into an
byte buffer. |
static int |
spool(java.io.InputStream in,
java.io.OutputStream out)
Spools data from an
InputStream into an
OutputStream . |
static int |
spool(java.io.InputStream in,
java.io.OutputStream out,
int num)
Spools data from an
InputStream into an
OutputStream . |
static int |
spool(java.io.Reader in,
java.io.Writer out)
Spools characters from an
Reader into an
Writer . |
static void |
tryClose(java.io.InputStream in)
Closes the
InputStream in if not
null and ignores a potential IOException thrown
from closing the stream. |
static void |
tryClose(java.io.OutputStream out)
Closes the
OutputStream out if not
null and ignores a potential IOException thrown
from closing the stream. |
static void |
tryClose(java.io.Reader reader)
Closes the
Reader out if not
null and ignores a potential IOException thrown
from closing the reader. |
static void |
tryClose(java.io.Writer writer)
Closes the
Writer in if not
null and ignores a potential IOException thrown
from closing the writer. |
public static int spool(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
InputStream
into an
OutputStream
. Please note, that both, input and output
stream, remain open after the spooling.in
- input streamout
- output streamjava.io.IOException
- if an I/O error occurspublic static int spool(java.io.InputStream in, byte[] buffer) throws java.io.IOException
InputStream
into an
byte buffer. either until the buffer is full or the EOF is reached.in
- input streambuffer
- output bufferjava.io.IOException
- if an I/O error occurspublic static int spool(java.io.Reader in, java.io.Writer out) throws java.io.IOException
Reader
into an
Writer
. Please note, that both, reader and writer remain
open after the spooling.in
- input Readerout
- output Writerjava.io.IOException
- if an I/O error occurspublic static int spool(java.io.InputStream in, java.io.OutputStream out, int num) throws java.io.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 streamjava.io.IOException
- if an I/O error occurspublic static void tryClose(java.io.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(java.io.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(java.io.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(java.io.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(java.io.File src, java.io.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 java.lang.String readUTF(java.io.InputStream in) throws java.io.UTFDataFormatException, java.io.IOException
in
- input streamjava.io.UTFDataFormatException
- if the input stream contains an invalid combination of bytesjava.io.IOException
- if an I/O error occurspublic static void setCWD(java.io.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(java.io.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(java.io.File tempDir)
tempDir
- temporary directory to usepublic static java.io.File getTempDir()
public static java.lang.String getAppHome()
getCWD()
.getPath()
instead.public static java.io.File getAppHomeDirectory()
getCWD()
instead.public static java.io.File getCWD()
public static java.io.File getCanonicalFile(java.lang.String path)
null
if the path cannot be
normalizedpublic static boolean isParent(java.io.File parent, java.io.File child)
parent
- parent filechild
- child filetrue
if parent is parent of child, otherwise
false
public static java.io.File createTempFile(java.util.Collection tracker) throws java.io.IOException
tracker
tracker
- collection that is use to record the generated temp file.java.io.IOException
- if an I/O error occurspublic static java.io.File createTempFile(java.util.Collection tracker, java.lang.String prefix, java.lang.String suffix) throws java.io.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 filejava.io.IOException
- if an I/O error occurspublic static java.io.File createTempFile() throws java.io.IOException
java.io.IOException
- if an I/O error occurspublic static java.io.File createTempFile(java.lang.String prefix, java.lang.String suffix) throws java.io.IOException
prefix
- the prefix for the filesuffix
- the suffix for the filejava.lang.IllegalArgumentException
- If the prefix argument contains fewer than three charactersjava.io.IOException
- If a file could not be createdpublic static java.lang.String getAbsolutePath(java.lang.String path)
path
already is absolute, this string itself is returned.path
- the relative pathpublic static java.io.File getAbsoluteFile(java.lang.String path)
path
- the relative pathpublic static boolean rename(java.io.File src, java.io.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 © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"