Package com.cedarsoftware.util
Class IOUtilities
java.lang.Object
com.cedarsoftware.util.IOUtilities
Useful IOUtilities that simplify common io tasks
- Author:
- Ken Partlow, John DeRegnaucourt ([email protected])
Copyright (c) Cedar Software LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
License
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic void
static void
close
(XMLStreamReader reader) static void
close
(XMLStreamWriter writer) static byte[]
compressBytes
(byte[] bytes) static byte[]
compressBytes
(byte[] bytes, int offset, int len) static void
compressBytes
(FastByteArrayOutputStream original, FastByteArrayOutputStream compressed) static void
compressBytes
(ByteArrayOutputStream original, ByteArrayOutputStream compressed) static void
static void
flush
(XMLStreamWriter writer) static InputStream
static byte[]
Convert InputStream contents to a byte[].static void
transfer
(File file, OutputStream out) static void
static void
transfer
(InputStream in, byte[] bytes) Use this when you expect a byte[] length of bytes to be read from the InputStreamstatic void
transfer
(InputStream s, File f, IOUtilities.TransferCallback cb) static void
transfer
(InputStream in, OutputStream out) Transfers bytes from an input stream to an output stream.static void
transfer
(InputStream in, OutputStream out, IOUtilities.TransferCallback cb) Transfers bytes from an input stream to an output stream.static void
transfer
(URLConnection c, byte[] bytes) Transfers a byte[] to the output stream of a URLConnectionstatic void
static byte[]
uncompressBytes
(byte[] bytes) static byte[]
uncompressBytes
(byte[] bytes, int offset, int len)
-
Method Details
-
getInputStream
- Throws:
IOException
-
transfer
public static void transfer(File f, URLConnection c, IOUtilities.TransferCallback cb) throws Exception - Throws:
Exception
-
transfer
public static void transfer(URLConnection c, File f, IOUtilities.TransferCallback cb) throws Exception - Throws:
Exception
-
transfer
public static void transfer(InputStream s, File f, IOUtilities.TransferCallback cb) throws Exception - Throws:
Exception
-
transfer
public static void transfer(InputStream in, OutputStream out, IOUtilities.TransferCallback cb) throws IOException Transfers bytes from an input stream to an output stream. Callers of this method are responsible for closing the streams since they are the ones that opened the streams.- Throws:
IOException
-
transfer
Use this when you expect a byte[] length of bytes to be read from the InputStream- Throws:
IOException
-
transfer
Transfers bytes from an input stream to an output stream. Callers of this method are responsible for closing the streams since they are the ones that opened the streams.- Throws:
IOException
-
transfer
- Throws:
IOException
-
close
-
close
-
close
-
flush
-
flush
-
inputStreamToBytes
Convert InputStream contents to a byte[]. Will return null on error. Only use this API if you know that the stream length will be relatively small. -
transfer
Transfers a byte[] to the output stream of a URLConnection- Parameters:
c
- Connection to transfer outputbytes
- the bytes to send- Throws:
IOException
-
compressBytes
public static void compressBytes(ByteArrayOutputStream original, ByteArrayOutputStream compressed) throws IOException - Throws:
IOException
-
compressBytes
public static void compressBytes(FastByteArrayOutputStream original, FastByteArrayOutputStream compressed) throws IOException - Throws:
IOException
-
compressBytes
public static byte[] compressBytes(byte[] bytes) -
compressBytes
public static byte[] compressBytes(byte[] bytes, int offset, int len) -
uncompressBytes
public static byte[] uncompressBytes(byte[] bytes) -
uncompressBytes
public static byte[] uncompressBytes(byte[] bytes, int offset, int len)
-