get ISO646 Bytes from String - Java java.lang

Java examples for java.lang:String Unicode

Description

get ISO646 Bytes from String

Demo Code


//package com.java2s;

import java.io.UnsupportedEncodingException;

public class Main {
    public static void main(String[] argv) {
        String str = "java2s.com";
        System.out.println(java.util.Arrays.toString(getISO646Bytes(str)));
    }//from w ww. j  av a2s .c o m

    static byte[] getISO646Bytes(String str) {
        try {
            return str.getBytes("ISO646-US");
        } catch (UnsupportedEncodingException uee) {
            throw new RuntimeException(uee);
        }
    }
}

Related Tutorials