Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;

public class Main {
    public static void main(String[] args) throws Exception {
        String os = "abc";
        for (byte b : os.getBytes("UTF-16BE")) {
            System.out.println(b);
        }

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        DataOutputStream dos = new DataOutputStream(baos);
        for (char c : os.toCharArray()) {
            dos.writeChar(c);
        }

        byte[] ba = baos.toByteArray();

        for (byte b : ba) {
            System.out.println(b);
        }
    }
}