Java Scanner Read readFile(File f)

Here you can find the source of readFile(File f)

Description

read File

License

Open Source License

Declaration

public static String readFile(File f) throws FileNotFoundException 

Method Source Code


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

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

import java.util.Scanner;

public class Main {
    public static String readFile(File f) throws FileNotFoundException {
        Scanner sc = new Scanner(f);
        StringBuilder sb = new StringBuilder();
        while (sc.hasNextLine())
            sb.append(sc.nextLine());// ww  w.jav a  2 s  .co  m
        sc.close();
        return sb.toString();
    }
}

Related

  1. read(Class clazz, String f)
  2. readArr(Scanner in, int n)
  3. readCQLFile(String cqlFileName)
  4. readFile(Class ownerClass, String fileName)
  5. readFile(File f)
  6. readFile(File f)
  7. readFile(File file)
  8. readFile(File file)
  9. readFile(File file)