Examples of encode()


Examples of org.apache.commons.codec.BinaryEncoder.encode()

        BinaryEncoder enc = new Base64();
        for (int i = 0; i < STRINGS.length; i++) {
            if (STRINGS[i] != null) {
                byte[] base64 = utf8(STRINGS[i]);
                byte[] binary = BYTES[i];
                boolean b = Arrays.equals(base64, enc.encode(binary));
                assertTrue("BinaryEncoder test-" + i, b);
            }
        }
    }

Examples of org.apache.commons.codec.Encoder.encode()

        WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/unauthorized-repo" );

        Encoder encoder = new Base64();
        String userPass = "unauthUser:unauthPass";
        String encodedUserPass = new String( (byte[]) encoder.encode( userPass.getBytes() ) );
        request.setHeaderField( "Authorization", "BASIC " + encodedUserPass );

        try
        {
            WebResponse resp = client.getResponse( request );

Examples of org.apache.commons.codec.binary.Base32.encode()

     * @param secretKey a random byte buffer.
     * @return the secret key.
     */
    private String calculateSecretKey(byte[] secretKey) {
        Base32 codec = new Base32();
        byte[] encodedKey = codec.encode(secretKey);

        // Creating a string with the Base32 encoded bytes.
        return new String(encodedKey);
    }

Examples of org.apache.commons.codec.binary.Base64.encode()

        byte[] rawHmac;
        try {
            data = stringToSign.getBytes(UTF8_CHARSET);
            rawHmac = mac.doFinal(data);
            Base64 encoder = new Base64();
            signature = new String(encoder.encode(rawHmac));
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(UTF8_CHARSET + " is unsupported!", e);
        }
        return signature;
    }

Examples of org.apache.commons.codec.binary.Hex.encode()

     */
    private static String displayByteFormat(Composite localComposite, byte[] byteArray, int numOfBytes,
                                            String encoding, String direction, boolean isHex)
    {
        final Hex hexeconder = new Hex();
        final byte[] encoded = hexeconder.encode(byteArray);

        int hexLength = byteArray.length * 2;
        StringBuilder sb = new StringBuilder();
        int currentBytePos = (Integer) localComposite.getData("currentBytePos");
        int startingBytePos = (Integer) localComposite.getData("startingBytePos");

Examples of org.apache.commons.codec.language.DoubleMetaphone.encode()

    params.set("selectedField", "1"); // tweet
    params.set("groupByField", "0"); // username
    ByKeyGroupingJob.startJob(params);
    DoubleMetaphone filter = new DoubleMetaphone();
// TODO: change these terms?!
    System.out.println(filter.encode("Loke"));
    System.out.println(filter.encode("companymancomic"));
    System.out.println(filter.encode("webcomics"));
    System.out.println(filter.encode("@comic"));
  }
}

Examples of org.apache.commons.codec.language.Metaphone.encode()

    Metaphone codec = new Metaphone();
    String phrase = "";
    String encoded = "";
    for(String s : args) {
      phrase += s.toUpperCase() + " ";
      encoded += codec.encode(s) + " ";
    }
   
    System.out.println("PHRASE =" + phrase);
    System.out.println("ENCODED=" + encoded);
  }

Examples of org.apache.commons.codec.language.RefinedSoundex.encode()

              int difference = -1;
              int length = 0;
              RefinedSoundex soundex = new RefinedSoundex();
              try {
                difference = soundex.difference(title1, title2);
                length = Math.max(soundex.encode(title1).length(), soundex.encode(title2).length());
              } catch (Exception e) {}
           
              double diff = (double)difference / (double)length;
              if(diff >= 0.75) {
                Duplicate d;

Examples of org.apache.commons.codec.net.QuotedPrintableCodec.encode()

 
  @Test
  public void testQuotedPrintableEncoding_1() throws UnsupportedEncodingException {
    String text = "This is a string with no special characters.";
    QuotedPrintableCodec QPC = new QuotedPrintableCodec();
    String encodedText = QPC.encode(text, "UTF8");
    assertEquals(text, encodedText);
  }
 
  @Test
  public void testQuotedPrintableEncoding_2() throws UnsupportedEncodingException {

Examples of org.apache.commons.codec.net.URLCodec.encode()

            NameValuePair pair = pairs[i];
            if (pair.getName() != null) {
                if (i > 0) {
                    buf.append("&");
                }
                buf.append(codec.encode(pair.getName(), charset));
                buf.append("=");
                if (pair.getValue() != null) {
                    buf.append(codec.encode(pair.getValue(), charset));
                }
            }
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.