Package org.apache.ofbiz.base.util
Class UtilIO
- java.lang.Object
-
- org.apache.ofbiz.base.util.UtilIO
-
public final class UtilIO extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
module
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
copy(java.io.Reader reader, java.lang.Appendable out)
Copy a Reader to an Appendable.static java.nio.charset.Charset
getUtf8()
static java.lang.String
readString(byte[] bytes)
Convert a byte array to a string; consistently uses \n line endings in java.static java.lang.String
readString(byte[] bytes, int offset, int length)
Convert a byte array to a string; consistently uses \n line endings in java.static java.lang.String
readString(byte[] bytes, int offset, int length, java.lang.String charset)
Convert a byte array to a string; consistently uses \n line endings in java.static java.lang.String
readString(byte[] bytes, int offset, int length, java.nio.charset.Charset charset)
Convert a byte array to a string, consistently uses \n line endings in java.static java.lang.String
readString(byte[] bytes, java.lang.String charset)
Convert a byte array to a string; consistently uses \n line endings in java.static java.lang.String
readString(byte[] bytes, java.nio.charset.Charset charset)
Convert a byte array to a string, consistently uses \n line endings in java.static java.lang.String
readString(java.io.InputStream stream)
Convert anInputStream
to a string; consistently uses \n line endings in java.static java.lang.String
readString(java.io.InputStream stream, java.lang.String charset)
Convert anInputStream
to a string; consistently uses \n line endings in java.static java.lang.String
readString(java.io.InputStream stream, java.nio.charset.Charset charset)
Convert anInputStream
to a string; consistently uses \n line endings in java.static java.lang.String
readString(java.io.Reader reader)
Convert anReader
to a string; consistently uses \n line endings in java.static void
writeString(java.io.File file, java.lang.String value)
Convert a \n string to a platform encoding.static void
writeString(java.io.OutputStream out, java.lang.String value)
Convert a \n string to a platform encoding.static void
writeString(java.io.OutputStream out, java.lang.String charset, java.lang.String value)
Convert a \n string to a platform encoding.static void
writeString(java.io.OutputStream out, java.nio.charset.Charset charset, java.lang.String value)
Convert a \n string to a platform encoding.
-
-
-
Method Detail
-
copy
public static void copy(java.io.Reader reader, java.lang.Appendable out) throws java.io.IOException
Copy a Reader to an Appendable.- Parameters:
reader
- the Reader to copy fromout
- the Appendable to copy to- Throws:
java.io.IOException
- if an error occurs
-
readString
public static final java.lang.String readString(byte[] bytes)
Convert a byte array to a string; consistently uses \n line endings in java. This uses a defaultUTF-8
charset.- Parameters:
bytes
- the array of bytes to convert- Returns:
- the converted string, with platform line endings converted to \n
-
readString
public static final java.lang.String readString(byte[] bytes, int offset, int length)
Convert a byte array to a string; consistently uses \n line endings in java. The conversion is limited to the specified offset/length pair, and uses a defaultUTF-8
charset.- Parameters:
bytes
- the array of bytes to convertoffset
- the start of the conversionlength
- how many bytes to convert- Returns:
- the converted string, with platform line endings converted to \n
-
readString
public static final java.lang.String readString(byte[] bytes, java.lang.String charset)
Convert a byte array to a string; consistently uses \n line endings in java. The conversion is limited to the specified offset/length pair, and uses the requested charset to decode the bytes.- Parameters:
bytes
- the array of bytes to convertcharset
- the charset to use to convert the raw bytes- Returns:
- the converted string, with platform line endings converted to \n
-
readString
public static final java.lang.String readString(byte[] bytes, int offset, int length, java.lang.String charset)
Convert a byte array to a string; consistently uses \n line endings in java. The conversion is limited to the specified offset/length pair, and uses the requested charset to decode the bytes.- Parameters:
bytes
- the array of bytes to convertoffset
- the start of the conversionlength
- how many bytes to convertcharset
- the charset to use to convert the raw bytes- Returns:
- the converted string, with platform line endings converted to \n
-
readString
public static final java.lang.String readString(byte[] bytes, java.nio.charset.Charset charset)
Convert a byte array to a string, consistently uses \n line endings in java. The specifiedcharset
is used to decode the bytes.- Parameters:
bytes
- the array of bytes to convertcharset
- the charset to use to convert the raw bytes- Returns:
- the converted string, with platform line endings converted to \n
-
readString
public static final java.lang.String readString(byte[] bytes, int offset, int length, java.nio.charset.Charset charset)
Convert a byte array to a string, consistently uses \n line endings in java. The conversion is limited to the specified offset/length pair, and uses the requestedcharset
to decode the bytes.- Parameters:
bytes
- the array of bytes to convertoffset
- the start of the conversionlength
- how many bytes to convertcharset
- the charset to use to convert the raw bytes- Returns:
- the converted string, with platform line endings converted to \n
-
readString
public static final java.lang.String readString(java.io.InputStream stream) throws java.io.IOException
Convert anInputStream
to a string; consistently uses \n line endings in java. This uses a defaultUTF-8
charset.- Parameters:
stream
- the stream of bytes to convert- Returns:
- the converted string, with platform line endings converted to \n
- Throws:
java.io.IOException
-
readString
public static final java.lang.String readString(java.io.InputStream stream, java.lang.String charset) throws java.io.IOException
Convert anInputStream
to a string; consistently uses \n line endings in java. This uses a defaultUTF-8
charset.- Parameters:
stream
- the stream of bytes to convertcharset
- the charset to use to convert the raw bytes- Returns:
- the converted string, with platform line endings converted to \n
- Throws:
java.io.IOException
-
readString
public static final java.lang.String readString(java.io.InputStream stream, java.nio.charset.Charset charset) throws java.io.IOException
Convert anInputStream
to a string; consistently uses \n line endings in java. This uses a defaultUTF-8
charset.- Parameters:
stream
- the stream of bytes to convertcharset
- the charset to use to convert the raw bytes- Returns:
- the converted string, with platform line endings converted to \n
- Throws:
java.io.IOException
-
readString
public static final java.lang.String readString(java.io.Reader reader) throws java.io.IOException
Convert anReader
to a string; consistently uses \n line endings in java.- Parameters:
reader
- the stream of characters convert- Returns:
- the converted string, with platform line endings converted to \n
- Throws:
java.io.IOException
-
writeString
public static void writeString(java.io.File file, java.lang.String value) throws java.io.IOException
Convert a \n string to a platform encoding. This uses a defaultUTF-8
charset.- Parameters:
file
- where to write the converted bytes tovalue
- the value to write- Throws:
java.io.IOException
-
writeString
public static void writeString(java.io.OutputStream out, java.lang.String value) throws java.io.IOException
Convert a \n string to a platform encoding. This uses a defaultUTF-8
charset.- Parameters:
out
- where to write the converted bytes tovalue
- the value to write- Throws:
java.io.IOException
-
writeString
public static void writeString(java.io.OutputStream out, java.lang.String charset, java.lang.String value) throws java.io.IOException
Convert a \n string to a platform encoding. This uses the specified charset to extract the raw bytes.- Parameters:
out
- where to write the converted bytes tocharset
- the charset to use to convert the raw bytesvalue
- the value to write- Throws:
java.io.IOException
-
writeString
public static void writeString(java.io.OutputStream out, java.nio.charset.Charset charset, java.lang.String value) throws java.io.IOException
Convert a \n string to a platform encoding. This uses the specified charset to extract the raw bytes.- Parameters:
out
- where to write the converted bytes tocharset
- the charset to use to convert the raw bytesvalue
- the value to write- Throws:
java.io.IOException
-
getUtf8
public static java.nio.charset.Charset getUtf8()
-
-