Java File to String fileToStringBuffer(File file)

Here you can find the source of fileToStringBuffer(File file)

Description

file To String Buffer

License

Open Source License

Declaration

public static StringBuffer fileToStringBuffer(File file) throws IOException 

Method Source Code

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

import java.io.BufferedReader;

import java.io.File;

import java.io.FileReader;

import java.io.IOException;

public class Main {
    public static StringBuffer fileToStringBuffer(File file) throws IOException {
        BufferedReader br = new BufferedReader(new FileReader(file));
        StringBuffer sb = new StringBuffer();
        try {/*from w  w  w.  ja v a  2  s.  co m*/
            String s = null;
            while ((s = br.readLine()) != null) {
                sb.append(s + "\n");
            }
        } finally {
            br.close();
        }

        return sb;
    }
}

Related

  1. fileToString(String nomeArquivo)
  2. fileToString(String path)
  3. fileToString(String pathname)
  4. fileToString(String strPath)
  5. fileToStringArray(String fileName)
  6. fileToStringList(File f)
  7. fileToStringList(String filePath)
  8. fileToStringOneLine(String path)
  9. readFileAsString(String filePath)