Java Scanner Read readFile(final File f)

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

Description

read File

License

Open Source License

Parameter

Parameter Description
f a parameter

Exception

Parameter Description
IOException an exception

Declaration

public static String readFile(final File f) throws IOException 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2013, 2014, 2015 QPark Consulting S.a r.l. This program and the
 * accompanying materials are made available under the terms of the Eclipse
 * Public License v1.0. The Eclipse Public License is available at
 * http://www.eclipse.org/legal/epl-v10.html.
 ******************************************************************************/

import java.io.File;

import java.io.IOException;

import java.util.Scanner;

public class Main {
    /**//from   w ww.j a  v  a2  s .c  om
     * @param f
     * @return
     * @throws IOException
     */
    public static String readFile(final File f) throws IOException {
        String s = null;
        if (f.exists()) {
            s = new Scanner(f).useDelimiter("\\A").next();
        }
        return s;
    }
}

Related

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