Package org.apache.ofbiz.base.util
Class UtilIO
java.lang.Object
org.apache.ofbiz.base.util.UtilIO
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
copy
(Reader reader, Appendable out) Copy a Reader to an Appendable.static String
readString
(byte[] bytes) Convert a byte array to a string; consistently uses \n line endings in java.static String
readString
(byte[] bytes, int offset, int length) Convert a byte array to a string; consistently uses \n line endings in java.static String
readString
(byte[] bytes, int offset, int length, String charset) Convert a byte array to a string; consistently uses \n line endings in java.static String
readString
(byte[] bytes, int offset, int length, Charset charset) Convert a byte array to a string, consistently uses \n line endings in java.static String
readString
(byte[] bytes, String charset) Convert a byte array to a string; consistently uses \n line endings in java.static String
readString
(byte[] bytes, Charset charset) Convert a byte array to a string, consistently uses \n line endings in java.static String
readString
(InputStream stream) Convert anInputStream
to a string; consistently uses \n line endings in java.static String
readString
(InputStream stream, String charset) Convert anInputStream
to a string; consistently uses \n line endings in java.static String
readString
(InputStream stream, Charset charset) Convert anInputStream
to a string; consistently uses \n line endings in java.static String
readString
(Reader reader) Convert anReader
to a string; consistently uses \n line endings in java.static void
writeString
(File file, String value) Convert a \n string to a platform encoding.static void
writeString
(OutputStream out, String value) Convert a \n string to a platform encoding.static void
writeString
(OutputStream out, String charset, String value) Convert a \n string to a platform encoding.static void
writeString
(OutputStream out, Charset charset, String value) Convert a \n string to a platform encoding.
-
Method Details
-
copy
Copy a Reader to an Appendable.- Parameters:
reader
- the Reader to copy fromout
- the Appendable to copy to- Throws:
IOException
- if an error occurs
-
readString
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
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
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
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
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
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
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:
IOException
-
readString
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:
IOException
-
readString
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:
IOException
-
readString
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:
IOException
-
writeString
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:
IOException
-
writeString
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:
IOException
-
writeString
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:
IOException
-
writeString
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:
IOException
-