Java InputStreamReader Read readFile(ZipInputStream zin)

Here you can find the source of readFile(ZipInputStream zin)

Description

read File

License

Open Source License

Declaration

public static String readFile(ZipInputStream zin) throws IOException 

Method Source Code


//package com.java2s;
/*//from w  w w  .ja  va2  s .c o m
 Bandika  - A Java based modular Content Management System
 Copyright (C) 2009-2018 Michael Roennau
    
 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 3 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/>.
 */

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;

import java.util.zip.ZipInputStream;

public class Main {
    public static String readFile(ZipInputStream zin) throws IOException {
        final char[] buffer = new char[0x2048];
        StringBuilder out = new StringBuilder();
        Reader in = new InputStreamReader(zin, "US-ASCII");
        int read;
        while ((read = in.read(buffer, 0, buffer.length)) > 0) {
            out.append(buffer, 0, read);
        }
        String s = out.toString();
        int startPos = 0;
        //check for utf-8 / endian start
        while (s.charAt(startPos) > 0xff) {
            startPos++;
        }
        if (startPos > 0) {
            s = s.substring(startPos);
        }
        return s;
    }
}

Related

  1. readFile(String Path)
  2. readFile(String path)
  3. readFile(String path)
  4. readFile(String path)
  5. readFile(String path, String charset)
  6. readFileAddLine(String filePath, Object object)
  7. readFileAll(File file, String charsetName)
  8. readFileAsArray(String path)
  9. readFileAsJson(String path)