Examples of DataEnd()


Examples of org.mozilla.universalchardet.UniversalDetector.dataEnd()

  private void checkForBadCharacters(String json) throws Exception
  {
    byte[] bytes = json.getBytes();   
    UniversalDetector ud = new UniversalDetector(null);
    ud.handleData(bytes, 0, bytes.length);
    ud.dataEnd();
    String encoding = ud.getDetectedCharset();     
    if ( encoding != null )
    {
      //do an extra check for charcode 65533 if encoding is utf-8   
      if ( encoding.equals("UTF-8"))
View Full Code Here

Examples of org.mozilla.universalchardet.UniversalDetector.dataEnd()

        do {
            int blockSize = Math.min(4096, bytes.length - offset);
            detector.handleData(bytes, offset, blockSize);
            offset += blockSize;
        } while(offset < bytes.length);
        detector.dataEnd();

        return or(detector.getDetectedCharset(), "UTF-8");
    }

    /**
 
View Full Code Here

Examples of org.mozilla.universalchardet.UniversalDetector.dataEnd()

        int nRead;

        while ((nRead = is.read(buf)) > 0 && !detector.isDone()) {
            detector.handleData(buf, 0, nRead);
        }
        detector.dataEnd();

        return or(detector.getDetectedCharset(), "UTF-8");
    }

    public static MediaType detectMediaType(File file, String name) throws IOException {
View Full Code Here

Examples of org.mozilla.universalchardet.UniversalDetector.dataEnd()

     */
    public static String guessEncoding(byte[] bytes) {
        String DEFAULT_ENCODING = "UTF-8";
        UniversalDetector detector = new UniversalDetector(null);
        detector.handleData(bytes, 0, bytes.length);
        detector.dataEnd();
        String encoding = detector.getDetectedCharset();
        detector.reset();
        if (encoding == null) {
            encoding = DEFAULT_ENCODING;
        }
View Full Code Here

Examples of org.mozilla.universalchardet.UniversalDetector.dataEnd()

        int nread;
        while ((nread = fis.read(buf)) > 0 && !detector.isDone()) {
            detector.handleData(buf, 0, nread);
        }
        // (3)
        detector.dataEnd();

        // (4)
        String encoding = detector.getDetectedCharset();
        if (encoding != null) {
            System.out.println("Detected encoding = " + encoding);
View Full Code Here

Examples of org.mozilla.universalchardet.UniversalDetector.dataEnd()

   */
  public static String detectEncoding(byte[] bytes) {
    String DEFAULT_ENCODING = "UTF-8";
    UniversalDetector detector = new UniversalDetector(null);
    detector.handleData(bytes, 0, bytes.length);
    detector.dataEnd();
    String encoding = detector.getDetectedCharset();
    detector.reset();
    if (encoding == null) {
      encoding = DEFAULT_ENCODING;
    } else if (encoding.equalsIgnoreCase("ISO-8859-1")) {
View Full Code Here

Examples of org.mozilla.universalchardet.UniversalDetector.dataEnd()

      int read = 0;
      while ((read = bc.read(buffer)) != -1) {
        detector.handleData(buffer.array(), buffer.position() - read, read);
        buffer = resizeBuffer(buffer);
      }
      detector.dataEnd();
      // copy the result back to a byte array
      String encoding = detector.getDetectedCharset();
      return new String(buffer.array(), 0, buffer.position(),
          encoding == null ? "UTF-8" : encoding);
    } finally {
View Full Code Here

Examples of org.mozilla.universalchardet.UniversalDetector.dataEnd()

    int numberOfBytesRead;
    while ((numberOfBytesRead = bufferedInputStream.read(buf)) > 0 && !universalDetector.isDone()) {
      universalDetector.handleData(buf, 0, numberOfBytesRead);
    }

    universalDetector.dataEnd();
    bufferedInputStream.close();
    String encoding = universalDetector.getDetectedCharset();

    if (encoding != null) {
      logger.debug("Detected encoding for {} is {}.", file.getAbsolutePath(), encoding);
View Full Code Here

Examples of org.mozilla.universalchardet.UniversalDetector.dataEnd()

    resource.mark(MAX_CHARSET_READAHEAD);
    int len = resource.read(bbuffer, 0, MAX_CHARSET_READAHEAD);
    resource.reset();
    detector.handleData(bbuffer, 0, len);
    // (3)
    detector.dataEnd();
    // (4)
    charsetName = detector.getDetectedCharset();

    // (5)
    detector.reset();
View Full Code Here

Examples of org.subethamail.smtp.client.SmartClient.dataEnd()

        smartClient.from("");
        smartClient.to("postmaster@example.org");
        smartClient.dataStart();
        byte[] bytes = ExampleMailData.simple().bytes;
        smartClient.dataWrite(bytes, bytes.length);
        smartClient.dataEnd();
        smartClient.quit();

        assertTrue(quitReceived);
        assertEquals(1, wiser.getMessages().size());
    }
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.