From 0f8bec94396647d4f2135bf653b177e7c1eb8759 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sun, 26 Aug 2012 22:37:38 +0200 Subject: [PATCH] Use Closer from utils. --- .../todesbaum/jsite/application/UpdateChecker.java | 2 +- .../java/de/todesbaum/jsite/gui/FileScanner.java | 2 +- .../de/todesbaum/jsite/main/Configuration.java | 2 +- src/main/java/de/todesbaum/util/io/Closer.java | 189 --------------------- 4 files changed, 3 insertions(+), 192 deletions(-) delete mode 100644 src/main/java/de/todesbaum/util/io/Closer.java diff --git a/src/main/java/de/todesbaum/jsite/application/UpdateChecker.java b/src/main/java/de/todesbaum/jsite/application/UpdateChecker.java index c49f166..1f55681 100644 --- a/src/main/java/de/todesbaum/jsite/application/UpdateChecker.java +++ b/src/main/java/de/todesbaum/jsite/application/UpdateChecker.java @@ -26,6 +26,7 @@ import java.util.Properties; import java.util.logging.Level; import java.util.logging.Logger; +import net.pterodactylus.util.io.Closer; import de.todesbaum.jsite.main.Main; import de.todesbaum.jsite.main.Version; import de.todesbaum.util.freenet.fcp2.Client; @@ -35,7 +36,6 @@ import de.todesbaum.util.freenet.fcp2.Message; import de.todesbaum.util.freenet.fcp2.Persistence; import de.todesbaum.util.freenet.fcp2.ReturnType; import de.todesbaum.util.freenet.fcp2.Verbosity; -import de.todesbaum.util.io.Closer; /** * Checks for newer versions of jSite. diff --git a/src/main/java/de/todesbaum/jsite/gui/FileScanner.java b/src/main/java/de/todesbaum/jsite/gui/FileScanner.java index 1790fbf..75dafe0 100644 --- a/src/main/java/de/todesbaum/jsite/gui/FileScanner.java +++ b/src/main/java/de/todesbaum/jsite/gui/FileScanner.java @@ -33,9 +33,9 @@ import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; +import net.pterodactylus.util.io.Closer; import de.todesbaum.jsite.application.Project; import de.todesbaum.jsite.i18n.I18n; -import de.todesbaum.util.io.Closer; import de.todesbaum.util.io.StreamCopier; /** diff --git a/src/main/java/de/todesbaum/jsite/main/Configuration.java b/src/main/java/de/todesbaum/jsite/main/Configuration.java index 12eb398..e3191de 100644 --- a/src/main/java/de/todesbaum/jsite/main/Configuration.java +++ b/src/main/java/de/todesbaum/jsite/main/Configuration.java @@ -35,6 +35,7 @@ import java.util.Map.Entry; import java.util.logging.Level; import java.util.logging.Logger; +import net.pterodactylus.util.io.Closer; import net.pterodactylus.util.xml.SimpleXML; import net.pterodactylus.util.xml.XML; import de.todesbaum.jsite.application.FileOption; @@ -43,7 +44,6 @@ import de.todesbaum.jsite.application.Project; import de.todesbaum.jsite.main.ConfigurationLocator.ConfigurationLocation; import de.todesbaum.util.freenet.fcp2.ClientPutDir.ManifestPutter; import de.todesbaum.util.freenet.fcp2.PriorityClass; -import de.todesbaum.util.io.Closer; import de.todesbaum.util.io.StreamCopier; /** diff --git a/src/main/java/de/todesbaum/util/io/Closer.java b/src/main/java/de/todesbaum/util/io/Closer.java deleted file mode 100644 index 67f7c57..0000000 --- a/src/main/java/de/todesbaum/util/io/Closer.java +++ /dev/null @@ -1,189 +0,0 @@ -/* - * jSite - Closer.java - Copyright © 2006–2012 David Roden - * - * This program 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 2 of the License, or (at your option) any later - * version. - * - * This program 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 - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -package de.todesbaum.util.io; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.Reader; -import java.io.Writer; -import java.net.ServerSocket; -import java.net.Socket; -import java.sql.Connection; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Statement; - -/** - * Helper class that can close all kinds of resources without throwing exception - * so that clean-up code can be written with less code. All methods check that - * the given resource is not null before invoking the close() - * method of the respective type. - * - * @author David ‘Bombe&squo; - * Roden - * @version $Id$ - */ -public class Closer { - - /** - * Closes the given result set. - * - * @param resultSet - * The result set to close - * @see ResultSet#close() - */ - public static void close(ResultSet resultSet) { - if (resultSet != null) { - try { - resultSet.close(); - } catch (SQLException ioe1) { - } - } - } - - /** - * Closes the given statement. - * - * @param statement - * The statement to close - * @see Statement#close() - */ - public static void close(Statement statement) { - if (statement != null) { - try { - statement.close(); - } catch (SQLException ioe1) { - } - } - } - - /** - * Closes the given connection. - * - * @param connection - * The connection to close - * @see Connection#close() - */ - public static void close(Connection connection) { - if (connection != null) { - try { - connection.close(); - } catch (SQLException ioe1) { - } - } - } - - /** - * Closes the given server socket. - * - * @param serverSocket - * The server socket to close - * @see ServerSocket#close() - */ - public static void close(ServerSocket serverSocket) { - if (serverSocket != null) { - try { - serverSocket.close(); - } catch (IOException ioe1) { - } - } - } - - /** - * Closes the given socket. - * - * @param socket - * The socket to close - * @see Socket#close() - */ - public static void close(Socket socket) { - if (socket != null) { - try { - socket.close(); - } catch (IOException ioe1) { - } - } - } - - /** - * Closes the given input stream. - * - * @param inputStream - * The input stream to close - * @see InputStream#close() - */ - public static void close(InputStream inputStream) { - if (inputStream != null) { - try { - inputStream.close(); - } catch (IOException ioe1) { - } - } - } - - /** - * Closes the given output stream. - * - * @param outputStream - * The output stream to close - * @see OutputStream#close() - */ - public static void close(OutputStream outputStream) { - if (outputStream != null) { - try { - outputStream.close(); - } catch (IOException ioe1) { - } - } - } - - /** - * Closes the given reader. - * - * @param reader - * The reader to close - * @see Reader#close() - */ - public static void close(Reader reader) { - if (reader != null) { - try { - reader.close(); - } catch (IOException ioe1) { - } - } - } - - /** - * Closes the given writer. - * - * @param writer - * The write to close - * @see Writer#close() - */ - public static void close(Writer writer) { - if (writer != null) { - try { - writer.close(); - } catch (IOException ioe1) { - } - } - } - -} -- 2.7.4