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 (jdereg@gmail.com)
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 voidstatic voidclose(XMLStreamReader reader) static voidclose(XMLStreamWriter writer) static byte[]compressBytes(byte[] bytes) static byte[]compressBytes(byte[] bytes, int offset, int len) static voidcompressBytes(FastByteArrayOutputStream original, FastByteArrayOutputStream compressed) static voidcompressBytes(ByteArrayOutputStream original, ByteArrayOutputStream compressed) static voidstatic voidflush(XMLStreamWriter writer) static InputStreamstatic byte[]Convert InputStream contents to a byte[].static voidtransfer(File file, OutputStream out) static voidstatic voidtransfer(InputStream in, byte[] bytes) Use this when you expect a byte[] length of bytes to be read from the InputStreamstatic voidtransfer(InputStream s, File f, IOUtilities.TransferCallback cb) static voidtransfer(InputStream in, OutputStream out) Transfers bytes from an input stream to an output stream.static voidtransfer(InputStream in, OutputStream out, IOUtilities.TransferCallback cb) Transfers bytes from an input stream to an output stream.static voidtransfer(URLConnection c, byte[] bytes) Transfers a byte[] to the output stream of a URLConnectionstatic voidstatic 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)
-