Java DataInputStream Read Line readLine(DataInputStream dis)

Here you can find the source of readLine(DataInputStream dis)

Description

Service routine

License

Open Source License

Parameter

Parameter Description
dis a parameter

Declaration

public static String readLine(DataInputStream dis) 

Method Source Code


//package com.java2s;
//License from project: MIT License 

import java.io.DataInputStream;

public class Main {
    /**// w  ww .  java 2s . c o m
     * Service routine
     * 
     * @param dis
     * @return
     */
    public static String readLine(DataInputStream dis) {
        String s = "";
        byte ch = 0;
        try {
            while ((ch = dis.readByte()) != -1) {
                // System.out.println("ch = "+ch);
                if (ch == '\n')
                    return s;
                s += (char) ch;
            }
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return s;
    }
}

Related

  1. readLine(DataInputStream ds)
  2. readLine(DataInputStream in)