Package java.nio.charset

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


           // muunnos onnistui source charactersettiin, voidaan yrittää muuntaa
           // kohde charactersettiin:
          
           ByteBuffer outputBuffer;
                          
           outputBuffer = tocharset.encode(data);
           byte[] tmp = outputBuffer.array();
           //String srtTest = new String(data);
           //String srtTest2 = new String(tmp);
           /*
           //System.out.println("data=" +srtTest);
View Full Code Here


           // muunnos onnistui source charactersettiin, voidaan yrittää muuntaa
           // kohde charactersettiin:
          
           ByteBuffer outputBuffer;
                          
           outputBuffer = tocharset.encode(data);
           byte[] tmp = outputBuffer.array();
           //String srtTest = new String(data);
           //String srtTest2 = new String(tmp);
           /*
           //System.out.println("data=" +srtTest);
View Full Code Here

    private Mac prf;

    private static byte[] getPasswordBytes(char[] passwd) {
        Charset utf8 = Charset.forName("UTF-8");
        CharBuffer cb = CharBuffer.wrap(passwd);
        ByteBuffer bb = utf8.encode(cb);

        int len = bb.limit();
        byte[] passwdBytes = new byte[len];
        bb.get(passwdBytes, 0, len);
View Full Code Here

            String charsetName = getCharsetName(rec.platformID,
                rec.platformSpecificID);
            Charset charset = Charset.forName(charsetName);
           
            // encode
            ByteBuffer strBuf = charset.encode(value);
            short strLen = (short) (strBuf.remaining() & 0xFFFF);
           
            // write the IDs
            buf.putShort(rec.platformID);
            buf.putShort(rec.platformSpecificID);
View Full Code Here

            String charsetName = getCharsetName(rec.platformID,
                rec.platformSpecificID);
            Charset charset = Charset.forName(charsetName);
           
            // encode
            ByteBuffer buf = charset.encode(value);
               
            // add the size of the coded buffer
            length += buf.remaining();
        }
       
View Full Code Here

    assertEquals("cable car", p.getProperty("type"));
  }
 
  public void testParseCommentsAndEmptyLines() throws Exception {
    Charset utf8 = Charset.forName(Parser.DATA_CHARSET);
    byte[] data = utf8.encode(COMMENTS_AND_EMPTY_LINES).array();
   
    Properties[] p = Parser.parse(new ByteArrayInputStream(data));
   
    assertNotNull(p);
    assertEquals(2, p.length);
View Full Code Here

    log.debug("passing input string: {}", inputStr);
    final String outputStr = echoService.echoString(inputStr);
    assertEquals("unequal strings", inputStr, outputStr);
    log.debug("got output string: {}", outputStr);

    java.nio.ByteBuffer outputBuf = cs.encode(outputStr);

    for (int i = 0; i < 7; i++) {
      assertEquals("unexpected byte", buf.get(i), outputBuf.get(i));
    }
  }
View Full Code Here

                            char[] buf = new char[(int) file.length()];
                            rdr.read(buf);
                            rdr.close();
                            CharBuffer cb = CharBuffer.wrap(buf);
                            Charset utf8 = Charset.forName("UTF-8");
                            ByteBuffer output = utf8.encode(cb);
                            ByteArrayInputStream data = new ByteArrayInputStream(output.array());
                            org.w3c.dom.Document dom = TidyParser.parse(data);
                            String title = "";
                            try {
                                JXPathContext ctx = JXPathContext.newContext(dom);
View Full Code Here

        if (!charset.equalsIgnoreCase("UTF-8")) {
            ByteBuffer input = ByteBuffer.wrap(data);
            Charset cs = Charset.forName(charset);
            CharBuffer cb = cs.decode(input);
            Charset utf8 = Charset.forName("UTF-8");
            ByteBuffer output = utf8.encode(cb);
            data = output.array();
        }
        return TidyParser.parse(new ByteArrayInputStream(data));
    }
View Full Code Here

      }
    }

    CharBuffer cb = CharBuffer.wrap(str);
    Charset cs = Charset.forName(encoding);
    ByteBuffer bb = cs.encode(cb);
    content = bb.array();
  }
 
  public String toString() {
    return new String(content);
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.