Java FileInputStream Read readFileUTF_8(String filePath)

Here you can find the source of readFileUTF_8(String filePath)

Description

read File UT_

License

Apache License

Declaration

public static String readFileUTF_8(String filePath) 

Method Source Code


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

import java.io.*;

public class Main {
    public static String readFileUTF_8(String filePath) {
        String templetContent = "";
        try {//ww w. ja va  2s  .c o  m
            FileInputStream fileinputstream = new FileInputStream(filePath);
            int length = fileinputstream.available();
            byte bytes[] = new byte[length];
            fileinputstream.read(bytes);
            fileinputstream.close();
            templetContent = new String(bytes, "UTF-8");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return templetContent;
    }
}

Related

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