Java BufferedReader Read readFile(String xmlFile)

Here you can find the source of readFile(String xmlFile)

Description

read File

License

Common Public License

Declaration

public static String readFile(String xmlFile) 

Method Source Code

//package com.java2s;
//License from project: Common Public License 

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;

public class Main {
    public static String readFile(String xmlFile) {
        StringBuffer fileContent = new StringBuffer();
        try {// w  w  w.  ja v  a2  s  .c  o m
            FileReader reader = new FileReader(new File(xmlFile));
            BufferedReader buffer = new BufferedReader(reader);
            String line = "";
            int i = 0;
            while ((line = buffer.readLine()) != null) {
                if (i != 0)
                    fileContent.append("\n");
                i++;
                fileContent.append(line);
            }
            reader.close();
        } catch (Exception ex) {

        }
        return fileContent.toString();
    }
}

Related

  1. readFile(String path)
  2. readFile(String path)
  3. readFile(String pathname)
  4. readFile(String sFileName_)
  5. readFile(String uri)
  6. readFileAsHash(File file)
  7. readFileAsLines(File fileLocation)
  8. readFileAsLines(String aFile)
  9. readFileAsList(final String filename)