Here you can find the source of close(File file)
Parameter | Description |
---|---|
file | The Desired File to close using Java API |
public static boolean close(File file)
//package com.java2s; /**/*from w w w . jav a2s .co m*/ * Copyright (c) 2013, Robert Cherry * All rights reserved. * * This file is part of the Faust Engine. * * The Faust Engine is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation, either version 3 of the License, or (at your option) any * later version. * * The Faust Engine is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * details. * * You should have received a copy of the GNU General Public License along with * the Faust Engine. If not, see <http://www.gnu.org/licenses/>. */ import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class Main { /** * Use this to close a File that has been opened by this Application * * @param file The Desired File to close using Java API * @return Whether or not the File was successfully closed */ public static boolean close(File file) { // Do not take null files if (file != null) { // Try - catch statement (IOException) try { // (Final) Input stream for the File final FileInputStream fis = new FileInputStream(file); // Close the channel that Java uses to communicate with the File fis.getChannel().close(); // Successfully close File return true; } catch (IOException ioe) { // This File was not successfully closed return false; } } // This File was not successfully closed. return false; } }