Java Code Examples for org.apache.commons.io.ByteOrderMark#UTF_32BE
The following examples show how to use
org.apache.commons.io.ByteOrderMark#UTF_32BE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MD5Digester.java From p4ic4idea with Apache License 2.0 | 5 votes |
private void digestEncodedStreamToUtf8(@Nonnull InputStream inStream, @Nonnull Charset charset, boolean isRequireLineEndingConvert, @Nullable ClientLineEnding clientLineEnding) throws IOException { try (BOMInputStream unicodeInputStream = new BOMInputStream(inStream, false, ByteOrderMark.UTF_8, ByteOrderMark.UTF_16LE, ByteOrderMark.UTF_16BE, ByteOrderMark.UTF_32LE, ByteOrderMark.UTF_32BE); InputStreamReader encodedStreamReader = new InputStreamReader(unicodeInputStream, charset)) { CharsetEncoder utf8CharsetEncoder = CharsetDefs.UTF8.newEncoder() .onMalformedInput(CodingErrorAction.REPORT) .onUnmappableCharacter(CodingErrorAction.REPORT); char[] buffer = new char[bufferSize]; int read; while ((read = encodedStreamReader.read(buffer)) > 0) { // Convert encoded stream to UTF8 since server digest is UTF8 ByteBuffer utf8ByteBuffer = utf8CharsetEncoder .encode(CharBuffer.wrap(buffer, 0, read)); if (isRequireLineEndingConvert) { ByteBuffer convert = findAndReplaceEncodedClientLineEndingIfRequireLineEndingCovert( encodedStreamReader, utf8CharsetEncoder, utf8ByteBuffer, clientLineEnding); update(convert.array(), convert.arrayOffset(), convert.limit()); } else { update(utf8ByteBuffer.array(), utf8ByteBuffer.arrayOffset(), utf8ByteBuffer.limit()); } } } }
Example 2
Source File: MD5Digester.java From p4ic4idea with Apache License 2.0 | 5 votes |
private void digestEncodedStreamToUtf8(@Nonnull InputStream inStream, @Nonnull Charset charset, boolean isRequireLineEndingConvert, @Nullable ClientLineEnding clientLineEnding) throws IOException { try (BOMInputStream unicodeInputStream = new BOMInputStream(inStream, false, ByteOrderMark.UTF_8, ByteOrderMark.UTF_16LE, ByteOrderMark.UTF_16BE, ByteOrderMark.UTF_32LE, ByteOrderMark.UTF_32BE); InputStreamReader encodedStreamReader = new InputStreamReader(unicodeInputStream, charset)) { CharsetEncoder utf8CharsetEncoder = CharsetDefs.UTF8.newEncoder() .onMalformedInput(CodingErrorAction.REPORT) .onUnmappableCharacter(CodingErrorAction.REPORT); char[] buffer = new char[bufferSize]; int read; while ((read = encodedStreamReader.read(buffer)) > 0) { // Convert encoded stream to UTF8 since server digest is UTF8 ByteBuffer utf8ByteBuffer = utf8CharsetEncoder .encode(CharBuffer.wrap(buffer, 0, read)); if (isRequireLineEndingConvert) { ByteBuffer convert = findAndReplaceEncodedClientLineEndingIfRequireLineEndingCovert( encodedStreamReader, utf8CharsetEncoder, utf8ByteBuffer, clientLineEnding); update(convert.array(), convert.arrayOffset(), convert.limit()); } else { update(utf8ByteBuffer.array(), utf8ByteBuffer.arrayOffset(), utf8ByteBuffer.limit()); } } } }
Example 3
Source File: MD5Digester.java From p4ic4idea with Apache License 2.0 | 5 votes |
private void digestEncodedStreamToUtf8(@Nonnull InputStream inStream, @Nonnull Charset charset, boolean isRequireLineEndingConvert, @Nullable ClientLineEnding clientLineEnding) throws IOException { try (BOMInputStream unicodeInputStream = new BOMInputStream(inStream, false, ByteOrderMark.UTF_8, ByteOrderMark.UTF_16LE, ByteOrderMark.UTF_16BE, ByteOrderMark.UTF_32LE, ByteOrderMark.UTF_32BE); InputStreamReader encodedStreamReader = new InputStreamReader(unicodeInputStream, charset)) { CharsetEncoder utf8CharsetEncoder = CharsetDefs.UTF8.newEncoder() .onMalformedInput(CodingErrorAction.REPORT) .onUnmappableCharacter(CodingErrorAction.REPORT); char[] buffer = new char[bufferSize]; int read; while ((read = encodedStreamReader.read(buffer)) > 0) { // Convert encoded stream to UTF8 since server digest is UTF8 ByteBuffer utf8ByteBuffer = utf8CharsetEncoder .encode(CharBuffer.wrap(buffer, 0, read)); if (isRequireLineEndingConvert) { ByteBuffer convert = findAndReplaceEncodedClientLineEndingIfRequireLineEndingCovert( encodedStreamReader, utf8CharsetEncoder, utf8ByteBuffer, clientLineEnding); update(convert.array(), convert.arrayOffset(), convert.limit()); } else { update(utf8ByteBuffer.array(), utf8ByteBuffer.arrayOffset(), utf8ByteBuffer.limit()); } } } }
Example 4
Source File: MD5Digester.java From p4ic4idea with Apache License 2.0 | 5 votes |
private void digestEncodedStreamToUtf8(@Nonnull InputStream inStream, @Nonnull Charset charset, boolean isRequireLineEndingConvert, @Nullable ClientLineEnding clientLineEnding) throws IOException { try (BOMInputStream unicodeInputStream = new BOMInputStream(inStream, false, ByteOrderMark.UTF_8, ByteOrderMark.UTF_16LE, ByteOrderMark.UTF_16BE, ByteOrderMark.UTF_32LE, ByteOrderMark.UTF_32BE); InputStreamReader encodedStreamReader = new InputStreamReader(unicodeInputStream, charset)) { CharsetEncoder utf8CharsetEncoder = CharsetDefs.UTF8.newEncoder() .onMalformedInput(CodingErrorAction.REPORT) .onUnmappableCharacter(CodingErrorAction.REPORT); char[] buffer = new char[bufferSize]; int read; while ((read = encodedStreamReader.read(buffer)) > 0) { // Convert encoded stream to UTF8 since server digest is UTF8 ByteBuffer utf8ByteBuffer = utf8CharsetEncoder .encode(CharBuffer.wrap(buffer, 0, read)); if (isRequireLineEndingConvert) { ByteBuffer convert = findAndReplaceEncodedClientLineEndingIfRequireLineEndingCovert( encodedStreamReader, utf8CharsetEncoder, utf8ByteBuffer, clientLineEnding); update(convert.array(), convert.arrayOffset(), convert.limit()); } else { update(utf8ByteBuffer.array(), utf8ByteBuffer.arrayOffset(), utf8ByteBuffer.limit()); } } } }
Example 5
Source File: StreamDecoder.java From batfish with Apache License 2.0 | 5 votes |
private static @Nonnull BOMInputStream bomInputStream(@Nonnull InputStream inputStream) { return new BOMInputStream( inputStream, ByteOrderMark.UTF_8, ByteOrderMark.UTF_16BE, ByteOrderMark.UTF_16LE, ByteOrderMark.UTF_32BE, ByteOrderMark.UTF_32LE); }