Here you can find the source of readFile(final File f)
Parameter | Description |
---|---|
f | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static String readFile(final File f) throws IOException
//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; } }