Java FileInputStream Read readFileUTF8(String file)

Here you can find the source of readFileUTF8(String file)

Description

read File UTF

License

Apache License

Declaration

public static String readFileUTF8(String file) 

Method Source Code

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

import java.io.DataInputStream;
import java.io.FileInputStream;

import java.io.IOException;

public class Main {
    public static String readFileUTF8(String file) {
        StringBuffer buffer = new StringBuffer();
        try {/*from   ww  w. ja v a2  s. c o m*/
            DataInputStream dis = new DataInputStream(new FileInputStream(file));
            byte b[] = new byte[1];

            while (dis.available() > 0) {
                dis.read(b);
                String s = new String(b, "UTF-8");
                buffer.append(s);
            }
            dis.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return buffer.toString();
    }
}

Related

  1. readFileToByteArray(String filename)
  2. readFileToBytes(File f)
  3. readFileToBytes(File f, int max)
  4. readFileToBytes(String path)
  5. readFileToStr(String fn, String charset)
  6. readFileUTF_8(String filePath)
  7. writeFile(File file, byte[] buffer, ZipOutputStream zos)
  8. writeFile(InputStream fileInputStream, OutputStream outputStream)
  9. writeFile(OutputStream os, File f)