Here you can find the source of readTextFile(final DataInputStream is)
Parameter | Description |
---|---|
is | DataInputStream |
Parameter | Description |
---|---|
IOException | if there is any problem with the DataInputStream |
public static String readTextFile(final DataInputStream is) throws IOException
//package com.java2s; /**/*from w ww . j a v a 2 s . com*/ * * Open Realm of Stars Game Project * Copyright (C) 2016 Tuomo Untinen * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see http://www.gnu.org/licenses/ * * * Generic IO Utilities * */ import java.io.DataInputStream; import java.io.IOException; public class Main { /** * Read file as text file return as US-ASCII string * @param is DataInputStream * @return String * @throws IOException if there is any problem with the DataInputStream */ public static String readTextFile(final DataInputStream is) throws IOException { byte[] dataBuf = new byte[is.available()]; is.readFully(dataBuf); return new String(dataBuf, "US-ASCII"); } }