FileUtils.java :  » UnTagged » wwwjdic » org » nick » wwwjdic » utils » Android Open Source

Android Open Source » UnTagged » wwwjdic 
wwwjdic » org » nick » wwwjdic » utils » FileUtils.java
package org.nick.wwwjdic.utils;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

public class FileUtils {

    private FileUtils() {
    }

    public static String readTextFile(InputStream in) throws IOException {
        return readTextFile(in, "ASCII");
    }

    public static String readTextFile(InputStream in, String encoding)
            throws IOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        byte buff[] = new byte[1024];

        int len = -1;
        while ((len = in.read(buff)) != -1) {
            baos.write(buff, 0, len);
        }

        return baos.toString(encoding);
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.