write Ascii String to OutputStream - Java java.io

Java examples for java.io:OutputStream

Description

write Ascii String to OutputStream

Demo Code


//package com.java2s;
import java.io.IOException;

import java.io.OutputStream;

public class Main {
    public static void writeOVMAsciiString(OutputStream os, String toWrite)
            throws IOException {
        int length = toWrite.length() < 256 ? toWrite.length() : 255;

        os.write(length);// www.  j a  v a2  s . c om
        for (int i = 0; i < length; ++i) {
            int code = toWrite.charAt(i);
            os.write(code);
        }
    }
}

Related Tutorials