Read Ascii String from InputStream - Java java.io

Java examples for java.io:InputStream Read

Description

Read Ascii String from InputStream

Demo Code


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

public class Main {
    static char[] textbuffer = new char[1000];

    public static String ReadAsciiString(InputStream is) throws IOException {
        int current;
        int index = 0;
        while ((current = is.read()) != 0) {
            textbuffer[index++] = (char) current;
        }/* ww w  . j  a  v  a2 s  .co m*/
        return new String(textbuffer, 0, index);
    }
}

Related Tutorials