|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sap.ip.me.api.services.IOUtils
This class contains some useful static methods for IO-operations.
Field Summary | |
static java.lang.String |
DEFAULT_CHARACTER_ENCODING
Default character encoding for the ME while writing or reading characters from Streams |
static java.io.InputStream |
termInputStream
Field to terminate connection |
Constructor Summary | |
IOUtils()
|
Method Summary | |
static boolean |
checkInputStream()
Checks whether InputStream that is sent to the URL is null or not |
static boolean |
closeInputStream()
Closes the InputStream that is sent to the URL. |
static void |
copyFile(java.io.File source,
java.io.File target,
int bufferLength)
Copies the content of the source to the target file in portions of length defined by bufferLength |
static void |
copyStreams(java.io.InputStream in,
java.io.OutputStream out)
Copys the input stream into the output stream. |
static void |
copyStreams(java.io.InputStream in,
java.io.OutputStream out,
boolean closeInputStream,
boolean closeOutputStream)
Copys the input stream into the output stream. |
static boolean |
deleteDirectoryRecursively(java.io.File dir)
Deletes a directory structure recusively including all files within the given directory and within all subdirectories. |
static boolean |
deleteDirectoryRecursively(java.io.File dir,
boolean deleteRootFolder)
Deletes a directory structure recusively including all files within the given directory and within all subdirectories. |
static java.io.File |
extractZipFile(java.util.zip.ZipFile zip,
java.util.zip.ZipEntry sourceEntry,
java.lang.String targetFilename)
Extract a ZipEntry out of a ZipFile . |
static long |
getTimeBetweenStreamCopy()
This methods returns the time that has been spent on copying streams since last reset. |
static void |
httpGet(java.lang.String sUrl,
java.io.OutputStream out)
Sends a http get request to the given url. |
static void |
httpGet(java.lang.String sUrl,
java.io.OutputStream out,
boolean compressed)
Sends a http get request to the given url. |
static void |
httpGet(java.lang.String sUrl,
java.lang.String destination)
Sends a http get request to the given url. |
static void |
httpGet(java.lang.String sUrl,
java.lang.String destination,
boolean compressed)
Sends a http get request to the given url. |
static void |
httpPost(java.lang.String sUrl,
int len,
java.io.InputStream in,
java.io.OutputStream out)
Wrapps the given inputstream into a http post request to the given url and writes the response into the given outputstream. |
static void |
httpPost(java.lang.String sUrl,
int len,
java.io.InputStream in,
java.io.OutputStream out,
boolean compressed)
Wrapps the given inputstream into a http post request to the given url and writes the response into the given outputstream. |
static void |
httpPost(java.lang.String sUrl,
java.lang.String source,
java.lang.String destination)
Sends a http post request to the given url. |
static void |
httpPost(java.lang.String sUrl,
java.lang.String source,
java.lang.String destination,
boolean compressed)
Sends a http post request to the given url. |
static void |
isConnectable(java.net.URL url)
Checks if a connection can be established to the given url. |
static void |
isConnectable(java.net.URL url,
java.lang.String userName,
java.lang.String password,
java.lang.String ssoTicket)
Checks if a connection can be established to the given url. |
static boolean |
moveFileToDirectory(java.io.File sourceFile,
java.io.File targetDirectory)
This method moves a file from it's original location to another directory. |
static java.util.Hashtable |
readHashtableFromDirectory(java.io.File directory)
creates hashtable from the given directory, from files, which are written to this directory via saveHashtableToDirectory(File directory, Hashtable hashtable)
method. |
static java.lang.Object |
readSerializedObjectFromFile(java.io.File file)
Reads a serialized object from the given file. |
static java.util.Vector |
readSerializedVectorFromFile(java.io.File file)
Reads a serialized vector from the given file. |
static void |
resetTimeBetweenStreamCopy()
This methods resets the counter that is used to measure the time spent on copyStreams. |
static void |
saveHashtableToDirectory(java.io.File directory,
java.util.Hashtable hashtable)
Saves this part of the given hashtable object, which can be serialized, to the given directory and ignores the rest. |
static void |
serializeObjectToFile(java.io.File file,
java.lang.Object object)
Serializes the given object to the given file. |
static void |
serializeVectorToFile(java.io.File file,
java.util.Vector vector)
Serializes the given vector object to the given file. |
static void |
setProxyAuthorization(java.net.URLConnection urlC)
Set the request property "Proxy-Authorization" for a given URLConnection
. |
static java.lang.String |
utf8AndUrlDecode(byte[] source,
int offset,
int len)
Decode a byte array from the "x-www-form-urlencoded" form, enhanced with the UTF-8-in-URL proposal. |
static java.lang.String |
utf8AndUrlEncode(java.lang.String s)
Encode a string to the "x-www-form-urlencoded" form, enhanced with the UTF-8-in-URL proposal. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String DEFAULT_CHARACTER_ENCODING
public static java.io.InputStream termInputStream
Constructor Detail |
public IOUtils()
Method Detail |
public static final java.lang.String utf8AndUrlEncode(java.lang.String s)
The ASCII characters 'a' through 'z', 'A' through 'Z', and '0' through '9' remain the same.
The unreserved characters - _ . ! ~ * ' ( ) remain the same.
The space character ' ' is converted into a plus sign '+'.
All other ASCII characters are converted into the 3-character string "%xy", where xy is the two-digit hexadecimal representation of the character code
All non-ASCII characters are encoded in two steps: first to a sequence of 2 or 3 bytes, using the UTF-8 algorithm; secondly each of these bytes is encoded as "%xx".
s
- The string to be encoded.
public static final java.lang.String utf8AndUrlDecode(byte[] source, int offset, int len)
utf8AndUrlEncode
.
source
- The byte array to be decoded.offset
- Description of the Parameterlen
- Description of the Parameter
public static void setProxyAuthorization(java.net.URLConnection urlC) throws java.io.UnsupportedEncodingException
URLConnection
.proxyauth.txt
Base64
encoding will be done.
urlC
- The URLConnection
java.io.UnsupportedEncodingException
- Description of the ExceptionConfiguration.getInstallationDirectory()
public static void httpPost(java.lang.String sUrl, int len, java.io.InputStream in, java.io.OutputStream out, boolean compressed) throws HttpConnectionException
sUrl
- The url for the http post request.len
- The length of the stream that will be
wrapped within the request.in
- The stream that should be send to the
url. This stream has to be opened at method call and after sending the
data this stream will be closed.out
- The response of the request will be
written to this stream. This stream has to be opened at method call
and after getting the response this stream will be closed.compressed
- Indicates whether the transfer of the
streams use compression or not.
HttpConnectionException
- If there are any IO exceptions while
transfering data a HttpConnectionException will be thrown.public static void httpPost(java.lang.String sUrl, int len, java.io.InputStream in, java.io.OutputStream out) throws HttpConnectionException
sUrl
- The url for the http post request.len
- Description of the Parameterin
- Description of the Parameterout
- Description of the Parameter
HttpConnectionException
- If there are any IO exceptions while
transfering data a HttpConnectionException will be thrown.public static void httpPost(java.lang.String sUrl, java.lang.String source, java.lang.String destination, boolean compressed) throws HttpConnectionException
sUrl
- The target url.source
- The source filename.destination
- The file name for the response.compressed
- Indicates whether the transfer uses
compression or not.
HttpConnectionException
- If there are any IO exceptions while
transfering data a HttpConnectionException will be thrown.public static void httpPost(java.lang.String sUrl, java.lang.String source, java.lang.String destination) throws HttpConnectionException
sUrl
- The target url.source
- The source filename.destination
- The file name for the response.
HttpConnectionException
- If there are any IO exceptions while
transfering data a HttpConnectionException will be thrown.public static void httpGet(java.lang.String sUrl, java.lang.String destination, boolean compressed) throws HttpConnectionException
sUrl
- The target url.destination
- The file name for the response.compressed
- Indicates whether the transfer uses
compression or not.
HttpConnectionException
- If there are any IO exceptions while
transfering data a HttpConnectionException will be thrown.public static void httpGet(java.lang.String sUrl, java.lang.String destination) throws HttpConnectionException
sUrl
- The target url.destination
- The file name for the response.
HttpConnectionException
- If there are any IO exceptions while
transfering data a HttpConnectionException will be thrown.public static void httpGet(java.lang.String sUrl, java.io.OutputStream out, boolean compressed) throws HttpConnectionException
sUrl
- The target url.out
- The response of the request will be
written to this stream. This stream has to be opened at method call
and after getting the response this stream will be closed.compressed
- Indicates whether the transfer uses
compression or not.
HttpConnectionException
- If there are any IO exceptions while
transfering data a HttpConnectionException will be thrown.public static void httpGet(java.lang.String sUrl, java.io.OutputStream out) throws HttpConnectionException
sUrl
- The target url.out
- The response of the request will be
written to this stream. This stream has to be opened at method call
and after getting the response this stream will be closed.
HttpConnectionException
- If there are any IO exceptions while
transfering data a HttpConnectionException will be thrown.public static void isConnectable(java.net.URL url) throws HttpConnectionException
SYNCSETTINGS_CONNECTION_TIMEOUT
is set to -1
the connection test will be ignored.
url
- The destination url.
HttpConnectionException
- If the connection test was not
successful a HttpConnectionException
will be thrown.public static void isConnectable(java.net.URL url, java.lang.String userName, java.lang.String password, java.lang.String ssoTicket) throws HttpConnectionException
SYNCSETTINGS_CONNECTION_TIMEOUT
is set to -1
the connection test will be ignored.null
MYSAPSSO2 cockie will be set. Otherwise if password
is not null
sap-password will be set to given password
and sap-user will be set to given username.
url
- The destination url.userName
- User name for authentication.password
- Password for authentication.ssoTicket
- MYSAPSSO2 ticket for authtentication.
HttpConnectionException
- If the connection test was not
successful a HttpConnectionException
will be thrown.public static void copyStreams(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
in
- The input stream.out
- The output stream.
java.io.IOException
public static void copyStreams(java.io.InputStream in, java.io.OutputStream out, boolean closeInputStream, boolean closeOutputStream) throws java.io.IOException
in
- The input stream.out
- The output stream.closeInputStream
- true iff the input stream should be closed after
copying.closeOutputStream
- true iff the output stream should be closed after
copying.
java.io.IOException
public static java.io.File extractZipFile(java.util.zip.ZipFile zip, java.util.zip.ZipEntry sourceEntry, java.lang.String targetFilename) throws java.io.IOException
ZipEntry
out of a ZipFile
. The target
filename is also given. The method returns a File
handle to
the extracted file. If there is an error while extracting a ZipEntry
an IOException will be thrown.
zip
- The source ZipFile
.sourceEntry
- The ZipEntry
that sould be extracted.targetFilename
- The target filename.
File
handle of the extracted file.
java.io.IOException
- IOException will be thrown if any error occurs.public static void serializeVectorToFile(java.io.File file, java.util.Vector vector)
null
nothing will be done.
file
- The destination file.vector
- The vector object that has to be serialized.public static void saveHashtableToDirectory(java.io.File directory, java.util.Hashtable hashtable)
directory
- The destination directory.hashtable
- The hashtable that has to be saved.readHashtableFromDirectory
public static java.util.Hashtable readHashtableFromDirectory(java.io.File directory)
saveHashtableToDirectory(File directory, Hashtable hashtable)
method. In other case an empty hasshtable will be returned
directory
- The destination directory.
saveHashtableToDirectory
public static void serializeObjectToFile(java.io.File file, java.lang.Object object)
null
nothing will be done.
file
- The destination file.object
- The object that has to be serialized.public static java.util.Vector readSerializedVectorFromFile(java.io.File file)
file
- The file.
public static java.lang.Object readSerializedObjectFromFile(java.io.File file)
file
- The file.
public static void copyFile(java.io.File source, java.io.File target, int bufferLength) throws java.io.IOException
source
- Source filetarget
- Target filebufferLength
- The size of buffer in character which will be used
for the copy
java.io.IOException
- seepublic static boolean deleteDirectoryRecursively(java.io.File dir)
dir
- The file or directory that has to be deleted.
public static boolean deleteDirectoryRecursively(java.io.File dir, boolean deleteRootFolder)
dir
- The file or directory that has to be deleted.deleteRootFolder
- true if dir should be deleted too.
public static long getTimeBetweenStreamCopy()
public static void resetTimeBetweenStreamCopy()
public static boolean moveFileToDirectory(java.io.File sourceFile, java.io.File targetDirectory)
sourceFile
- The original filetargetDirectory
- The directory to which the sourceFile will be moved
true
if the move was successfull,
false
if the move was not successfull, if one of the two
parameters was null
, if targetDirectory.isFile()
or if sourceFile.isDirectory()
public static boolean closeInputStream()
true
if InputStream was closed successfully
false
otherwise.public static boolean checkInputStream()
true
if InputStream is not null
false
otherwise.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |