Java Scanner Read readFile(File file)

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

Description

read File

License

Apache License

Declaration

public static String readFile(File file) throws FileNotFoundException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
    private static final String MULTILINE_START_ANCHOR_REGEX = "\\A";

    public static String readFile(String filename) throws FileNotFoundException {
        return readFile(new File(filename));
    }//w ww. ja v  a2  s. c om

    public static String readFile(File file) throws FileNotFoundException {
        Scanner scanner = new Scanner(file);
        String ret = scanner.useDelimiter(MULTILINE_START_ANCHOR_REGEX).next();
        scanner.close();
        return ret;
    }
}

Related

  1. readFile(File f)
  2. readFile(File f)
  3. readFile(File f)
  4. readFile(File file)
  5. readFile(File file)
  6. readFile(File file)
  7. readFile(File file)
  8. readFile(File file)
  9. readFile(File input)