Java File to String fileToString(String fileName)

Here you can find the source of fileToString(String fileName)

Description

file To String

License

Open Source License

Declaration

public static String fileToString(String fileName) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.*;

public class Main {
    public static String fileToString(String fileName) throws IOException {
        String result = "";
        try {/*from   w  ww. ja  va2  s  .c om*/
            FileInputStream file = new FileInputStream(fileName);
            byte[] b = new byte[file.available()];
            file.read(b);
            file.close();
            result = new String(b);
        } catch (FileNotFoundException e) {
            System.out.println("oops");
        }
        return result;

    }
}

Related

  1. FileToString(String file_name)
  2. fileToString(String filename)
  3. fileToString(String filename)
  4. fileToString(String fileName)
  5. fileToString(String fileName)
  6. fileToString(String filename)
  7. fileToString(String filename)
  8. fileToString(String fileName)
  9. fileToString(String fileName)