Java File Content Read getFileContents(File methodPatch)

Here you can find the source of getFileContents(File methodPatch)

Description

get File Contents

License

Open Source License

Parameter

Parameter Description
methodPatch a parameter

Declaration

public static String getFileContents(File methodPatch) 

Method Source Code


//package com.java2s;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;

import java.util.Scanner;

public class Main {
    /**/*from   w  w w.ja va2s .  co  m*/
     * @param methodPatch
     * @return
     */
    public static String getFileContents(File methodPatch) {
        Scanner file;
        try {
            file = new Scanner(new FileInputStream(methodPatch));
            StringBuilder out = new StringBuilder();
            while (file.hasNext()) {
                out.append(file.next());
            }
            return out.toString();
        } catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return "";
        }
    }
}

Related

  1. getFileContent(String pythonSource)
  2. getFileContents(File f)
  3. getFileContents(File f)
  4. getFileContents(File file)
  5. getFileContents(File file)
  6. getFileContents(File testFile)
  7. getFileContents(final File f)
  8. getFileContents(final File file)
  9. getFileContents(String filename)