Java Scanner Read readFile(File path)

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

Description

read File

License

Open Source License

Declaration

public static String readFile(File path) 

Method Source Code

//package com.java2s;
/**************************************************************************************
*  Copyright (c) 2013, Universitat Politecnica de Valencia. All rights reserved.      *
*  This program and the accompanying materials are made available under the terms     *
*  of the 3-Clause BSD License which accompanies this distribution, and is available  *
*  at http://www.opensource.org/licenses/BSD-3-Clause. The research leading to these  *
*  results has received funding from the European Community`s Seventh Framework       *
*  Programme (FP7/2007-2013) under the grant agreement  FP7-257574 FITTEST.           *
**************************************************************************************/

import java.io.File;

import java.io.FileNotFoundException;

import java.util.Scanner;

public class Main {
    public static String readFile(File path) {
        try {//w w w .  j  a v a 2s. co  m
            return new Scanner(path, "UTF-8").useDelimiter("\\A").next();
        } catch (FileNotFoundException ex) {
            return null;
        }
    }
}

Related

  1. readFile(File file)
  2. readFile(File file)
  3. readFile(File file)
  4. readFile(File file)
  5. readFile(File input)
  6. readFile(final File f)
  7. readFile(String file_name)
  8. readFile(String filename)
  9. readFile(String fileName)