Java Code Examples for java.nio.charset.CodingErrorAction#REPORT
The following examples show how to use
java.nio.charset.CodingErrorAction#REPORT .
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: B2CConverter.java From Tomcat8-Source-Read with MIT License | 6 votes |
public B2CConverter(Charset charset, boolean replaceOnError) { byte[] left = new byte[LEFTOVER_SIZE]; leftovers = ByteBuffer.wrap(left); CodingErrorAction action; if (replaceOnError) { action = CodingErrorAction.REPLACE; } else { action = CodingErrorAction.REPORT; } // Special case. Use the Apache Harmony based UTF-8 decoder because it // - a) rejects invalid sequences that the JVM decoder does not // - b) fails faster for some invalid sequences if (charset.equals(StandardCharsets.UTF_8)) { decoder = new Utf8Decoder(); } else { decoder = charset.newDecoder(); } decoder.onMalformedInput(action); decoder.onUnmappableCharacter(action); }
Example 2
Source File: BaseFileManager.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public CharsetDecoder getDecoder(String encodingName, boolean ignoreEncodingErrors) { Charset cs = (this.charset == null) ? Charset.forName(encodingName) : this.charset; CharsetDecoder decoder = cs.newDecoder(); CodingErrorAction action; if (ignoreEncodingErrors) action = CodingErrorAction.REPLACE; else action = CodingErrorAction.REPORT; return decoder .onMalformedInput(action) .onUnmappableCharacter(action); }
Example 3
Source File: BaseFileManager.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public CharsetDecoder getDecoder(String encodingName, boolean ignoreEncodingErrors) { Charset cs = (this.charset == null) ? Charset.forName(encodingName) : this.charset; CharsetDecoder decoder = cs.newDecoder(); CodingErrorAction action; if (ignoreEncodingErrors) action = CodingErrorAction.REPLACE; else action = CodingErrorAction.REPORT; return decoder .onMalformedInput(action) .onUnmappableCharacter(action); }
Example 4
Source File: BaseFileManager.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
public CharsetDecoder getDecoder(String encodingName, boolean ignoreEncodingErrors) { Charset cs = (this.charset == null) ? Charset.forName(encodingName) : this.charset; CharsetDecoder decoder = cs.newDecoder(); CodingErrorAction action; if (ignoreEncodingErrors) action = CodingErrorAction.REPLACE; else action = CodingErrorAction.REPORT; return decoder .onMalformedInput(action) .onUnmappableCharacter(action); }
Example 5
Source File: BaseFileManager.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public CharsetDecoder getDecoder(String encodingName, boolean ignoreEncodingErrors) { Charset cs = (this.charset == null) ? Charset.forName(encodingName) : this.charset; CharsetDecoder decoder = cs.newDecoder(); CodingErrorAction action; if (ignoreEncodingErrors) action = CodingErrorAction.REPLACE; else action = CodingErrorAction.REPORT; return decoder .onMalformedInput(action) .onUnmappableCharacter(action); }
Example 6
Source File: BaseFileManager.java From lua-for-android with BSD 3-Clause "New" or "Revised" License | 6 votes |
public CharsetDecoder getDecoder(String encodingName, boolean ignoreEncodingErrors) { Charset cs = (this.charset == null) ? Charset.forName(encodingName) : this.charset; CharsetDecoder decoder = cs.newDecoder(); CodingErrorAction action; if (ignoreEncodingErrors) action = CodingErrorAction.REPLACE; else action = CodingErrorAction.REPORT; return decoder .onMalformedInput(action) .onUnmappableCharacter(action); }
Example 7
Source File: B2CConverter.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
public B2CConverter(String encoding, boolean replaceOnError) throws IOException { byte[] left = new byte[LEFTOVER_SIZE]; leftovers = ByteBuffer.wrap(left); CodingErrorAction action; if (replaceOnError) { action = CodingErrorAction.REPLACE; } else { action = CodingErrorAction.REPORT; } Charset charset = getCharset(encoding); // Special case. Use the Apache Harmony based UTF-8 decoder because it // - a) rejects invalid sequences that the JVM decoder does not // - b) fails faster for some invalid sequences if (charset.equals(UTF_8)) { decoder = new Utf8Decoder(); } else { decoder = charset.newDecoder(); } decoder.onMalformedInput(action); decoder.onUnmappableCharacter(action); }
Example 8
Source File: BaseFileManager.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public CharsetDecoder getDecoder(String encodingName, boolean ignoreEncodingErrors) { Charset cs = (this.charset == null) ? Charset.forName(encodingName) : this.charset; CharsetDecoder decoder = cs.newDecoder(); CodingErrorAction action; if (ignoreEncodingErrors) action = CodingErrorAction.REPLACE; else action = CodingErrorAction.REPORT; return decoder .onMalformedInput(action) .onUnmappableCharacter(action); }
Example 9
Source File: BaseFileManager.java From javaide with GNU General Public License v3.0 | 6 votes |
public CharsetDecoder getDecoder(String encodingName, boolean ignoreEncodingErrors) { Charset cs = (this.charset == null) ? Charset.forName(encodingName) : this.charset; CharsetDecoder decoder = cs.newDecoder(); CodingErrorAction action; if (ignoreEncodingErrors) action = CodingErrorAction.REPLACE; else action = CodingErrorAction.REPORT; return decoder .onMalformedInput(action) .onUnmappableCharacter(action); }
Example 10
Source File: BaseFileManager.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public CharsetDecoder getDecoder(String encodingName, boolean ignoreEncodingErrors) { Charset cs = (this.charset == null) ? Charset.forName(encodingName) : this.charset; CharsetDecoder decoder = cs.newDecoder(); CodingErrorAction action; if (ignoreEncodingErrors) action = CodingErrorAction.REPLACE; else action = CodingErrorAction.REPORT; return decoder .onMalformedInput(action) .onUnmappableCharacter(action); }
Example 11
Source File: TracingManagedHttpClientConnectionFactory.java From caravan with Apache License 2.0 | 6 votes |
@Override public ManagedHttpClientConnection create(final HttpRoute route, final ConnectionConfig config) { final ConnectionConfig cconfig = config != null ? config : ConnectionConfig.DEFAULT; CharsetDecoder chardecoder = null; CharsetEncoder charencoder = null; final Charset charset = cconfig.getCharset(); final CodingErrorAction malformedInputAction = cconfig.getMalformedInputAction() != null ? cconfig.getMalformedInputAction() : CodingErrorAction.REPORT; final CodingErrorAction unmappableInputAction = cconfig.getUnmappableInputAction() != null ? cconfig.getUnmappableInputAction() : CodingErrorAction.REPORT; if (charset != null) { chardecoder = charset.newDecoder(); chardecoder.onMalformedInput(malformedInputAction); chardecoder.onUnmappableCharacter(unmappableInputAction); charencoder = charset.newEncoder(); charencoder.onMalformedInput(malformedInputAction); charencoder.onUnmappableCharacter(unmappableInputAction); } final String id = "http-outgoing-" + Long.toString(COUNTER.getAndIncrement()); return new TracingManagedHttpClientConnection(id, cconfig.getBufferSize(), cconfig.getFragmentSizeHint(), chardecoder, charencoder, cconfig.getMessageConstraints(), incomingContentStrategy, outgoingContentStrategy, requestWriterFactory, responseParserFactory, logFunc); }
Example 12
Source File: BaseFileManager.java From hottub with GNU General Public License v2.0 | 6 votes |
public CharsetDecoder getDecoder(String encodingName, boolean ignoreEncodingErrors) { Charset cs = (this.charset == null) ? Charset.forName(encodingName) : this.charset; CharsetDecoder decoder = cs.newDecoder(); CodingErrorAction action; if (ignoreEncodingErrors) action = CodingErrorAction.REPLACE; else action = CodingErrorAction.REPORT; return decoder .onMalformedInput(action) .onUnmappableCharacter(action); }
Example 13
Source File: BaseFileManager.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public CharsetDecoder getDecoder(String encodingName, boolean ignoreEncodingErrors) { Charset cs = (this.charset == null) ? Charset.forName(encodingName) : this.charset; CharsetDecoder decoder = cs.newDecoder(); CodingErrorAction action; if (ignoreEncodingErrors) action = CodingErrorAction.REPLACE; else action = CodingErrorAction.REPORT; return decoder .onMalformedInput(action) .onUnmappableCharacter(action); }
Example 14
Source File: BaseFileManager.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public CharsetDecoder getDecoder(String encodingName, boolean ignoreEncodingErrors) { Charset cs = (this.charset == null) ? Charset.forName(encodingName) : this.charset; CharsetDecoder decoder = cs.newDecoder(); CodingErrorAction action; if (ignoreEncodingErrors) action = CodingErrorAction.REPLACE; else action = CodingErrorAction.REPORT; return decoder .onMalformedInput(action) .onUnmappableCharacter(action); }
Example 15
Source File: B2CConverter.java From tomcatsrc with Apache License 2.0 | 6 votes |
public B2CConverter(String encoding, boolean replaceOnError) throws IOException { byte[] left = new byte[LEFTOVER_SIZE]; leftovers = ByteBuffer.wrap(left); CodingErrorAction action; if (replaceOnError) { action = CodingErrorAction.REPLACE; } else { action = CodingErrorAction.REPORT; } Charset charset = getCharset(encoding); // Special case. Use the Apache Harmony based UTF-8 decoder because it // - a) rejects invalid sequences that the JVM decoder does not // - b) fails faster for some invalid sequences if (charset.equals(UTF_8)) { decoder = new Utf8Decoder(); } else { decoder = charset.newDecoder(); } decoder.onMalformedInput(action); decoder.onUnmappableCharacter(action); }
Example 16
Source File: EmptyLombokFileObject.java From EasyMPermission with MIT License | 4 votes |
@Override public CharsetDecoder getDecoder(boolean ignoreEncodingErrors) { CharsetDecoder decoder = Charset.forName("UTF-8").newDecoder(); CodingErrorAction action = ignoreEncodingErrors ? CodingErrorAction.REPLACE : CodingErrorAction.REPORT; return decoder.onMalformedInput(action).onUnmappableCharacter(action); }