Examples of newDecoder()


Examples of java.nio.charset.Charset.newDecoder()

      throws IOException {
    UnknownDictionaryWriter dictionary = new UnknownDictionaryWriter(5 * 1024 * 1024);
   
    FileInputStream inputStream = new FileInputStream(filename);
    Charset cs = Charset.forName(encoding);
    CharsetDecoder decoder = cs.newDecoder()
        .onMalformedInput(CodingErrorAction.REPORT)
        .onUnmappableCharacter(CodingErrorAction.REPORT);
    InputStreamReader streamReader = new InputStreamReader(inputStream, decoder);
    LineNumberReader lineReader = new LineNumberReader(streamReader);
   
View Full Code Here

Examples of java.nio.charset.Charset.newDecoder()

    System.out.println("  parse...");
    List<String[]> lines = new ArrayList<String[]>(400000);
    for (File file : csvFiles){
      FileInputStream inputStream = new FileInputStream(file);
      Charset cs = Charset.forName(encoding);
      CharsetDecoder decoder = cs.newDecoder()
          .onMalformedInput(CodingErrorAction.REPORT)
          .onUnmappableCharacter(CodingErrorAction.REPORT);
      InputStreamReader streamReader = new InputStreamReader(inputStream, decoder);
      BufferedReader reader = new BufferedReader(streamReader);
     
View Full Code Here

Examples of java.nio.charset.Charset.newDecoder()

            FileChannel channel = input.getChannel();
            long fileLength = channel.size();
            MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, fileLength);
            // character buffer
            Charset charset = java.nio.charset.Charset.forName("UTF-8");
            CharsetDecoder decoder = charset.newDecoder();
            return decoder.decode(buffer);
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
View Full Code Here

Examples of java.nio.charset.Charset.newDecoder()

            FileChannel channel = input.getChannel();
            long fileLength = channel.size();
            MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_ONLY, 0, fileLength);
            // character buffer
            Charset charset = java.nio.charset.Charset.forName("UTF-8");
            CharsetDecoder decoder = charset.newDecoder();
            return decoder.decode(buffer);
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
View Full Code Here

Examples of java.nio.charset.Charset.newDecoder()

    }

    private CharBuffer openBuffer(IFile f) throws IOException, CoreException
    {
        Charset charset = Charset.forName(f.getCharset());
        CharsetDecoder decoder = charset.newDecoder();
        // Open the file and then get a channel from the stream
        FileInputStream fis = new FileInputStream(f.getLocation().toFile());
        fc = fis.getChannel();

        // Get the file's size and then map it into memory
View Full Code Here

Examples of java.nio.charset.Charset.newDecoder()

    Charset charset = Charset.forName("US-ASCII");

    try {
      InputStream in = env.getMessageInputStream();
      byte[] buf = new byte[16384];
      CharsetDecoder decoder = charset.newDecoder();
      int len = 0;
      while ((len = in.read(buf)) >= 0) {
        session.getLogger().trace(decoder.decode(ByteBuffer.wrap(buf, 0, len)).toString());
      }
    } catch (IOException ioex) {
View Full Code Here

Examples of java.nio.charset.Charset.newDecoder()

   */
  public URIDecodingFilter(final TokenStream input, final String charsetEncoding)
  throws UnsupportedCharsetException {
    super(input);
    final Charset charset = this.lookupCharset(charsetEncoding);
    charsetDecoder = charset.newDecoder()
                            .onMalformedInput(CodingErrorAction.REPLACE)
                            .onUnmappableCharacter(CodingErrorAction.REPLACE);
    termAtt = this.addAttribute(CharTermAttribute.class);
    posIncrAtt = this.addAttribute(PositionIncrementAttribute.class);
    termBuffer = CharBuffer.allocate(256);
View Full Code Here

Examples of java.nio.charset.Charset.newDecoder()

    Charset utf8 = getUTF8();
    if (fsEncoding.equals(utf8)) {
      utfDecoder = decoder;
      utfEncoder = encoder;
    } else {
      utfDecoder = utf8.newDecoder();
      utfEncoder = utf8.newEncoder();
    }
  }

  /**
 
View Full Code Here

Examples of java.nio.charset.Charset.newDecoder()

        MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, sz);

  // Decode the file into a char buffer
        // Charset and decoder for ISO-8859-15
        Charset charset = Charset.forName("ISO-8859-15");
        CharsetDecoder decoder = charset.newDecoder();
  CharBuffer cb = decoder.decode(bb);

        Matcher matcher = pattern.matcher(cb);
        String outString = matcher.replaceAll(substituteReplacement);
        log.debug(outString);
View Full Code Here

Examples of java.nio.charset.Charset.newDecoder()

        }
        this.substitute = substitute;
        this.outputCharset = outputCharset;
        this.stream = os;
        Charset cs = Charset.forName(outputCharset);
        cd = cs.newDecoder().onMalformedInput(CodingErrorAction.REPORT).onUnmappableCharacter(CodingErrorAction.REPLACE);
    }

    /*
     * Decode the bytes in the byte buffer and append to the char buffer.
     *
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.