read ISO646 String from DataInputStream - Java java.io

Java examples for java.io:InputStream Read

Description

read ISO646 String from DataInputStream

Demo Code


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

public class Main {
    static String readISO646String(DataInputStream dis, int len)
            throws IOException {
        byte[] buf = new byte[len];
        dis.read(buf);//from   ww w .j a  v  a 2  s  .c o  m
        return iso646String(buf);
    }

    static String iso646String(byte[] buf) {
        try {
            return new String(buf, "ISO646-US");
        } catch (UnsupportedEncodingException uee) {
            throw new RuntimeException(uee);
        }
    }
}

Related Tutorials