diff src/main/java/nl/cwi/monetdb/util/Extract.java @ 307:05549bc7ed26

Add "final" keyword to classes, method arguments and local variables where possible.
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Wed, 21 Aug 2019 19:16:02 +0200 (2019-08-21)
parents d4baf8a4b43a
children 8a96a4a13528
line wrap: on
line diff
--- a/src/main/java/nl/cwi/monetdb/util/Extract.java
+++ b/src/main/java/nl/cwi/monetdb/util/Extract.java
@@ -12,9 +12,6 @@ import java.io.BufferedReader;
 import java.io.FileNotFoundException;
 import java.io.FileWriter;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
 
 /**
  * This file contains a function to extract files from its including Jar
@@ -23,41 +20,37 @@ import java.io.InputStreamReader;
  * @author Ying Zhang "Y.Zhang@cwi.nl"
  * @version 0.1
  */
-
 public class Extract {
 	private static final int DEFAULT_BUFSIZE = 16386;
 
-    public Extract() {}
+	public Extract() {}
 
-    /**
-     * Extracts a file from the Jar package which includes this class to
-     * the given destination
-     * @param fromFile The file to extract, including it absolute path
-     * inside its including Jar package.
-     * @param toFile Destination for the extracted file
-     * @throws FileNotFoundException If the file to extract can not be
-     * found in its including Jar package.
-     * @throws IOException If any error happens during
-     * creating/reading/writing files.
-     */
-	public static void extractFile(String fromFile, String toFile)
+	/**
+	 * Extracts a file from the Jar package which includes this class to
+	 * the given destination
+	 * @param fromFile The file to extract, including it absolute path
+	 * inside its including Jar package.
+	 * @param toFile Destination for the extracted file
+	 * @throws FileNotFoundException If the file to extract can not be
+	 * found in its including Jar package.
+	 * @throws IOException If any error happens during
+	 * creating/reading/writing files.
+	 */
+	public static void extractFile(final String fromFile, final String toFile)
 		throws FileNotFoundException, IOException
 	{
-		char[] cbuf = new char[DEFAULT_BUFSIZE];
-		int ret = 0;
-
-		InputStream is = new Extract().getClass().getResourceAsStream(fromFile);
-
-		if(is == null) {
+		java.io.InputStream is = new Extract().getClass().getResourceAsStream(fromFile);
+		if (is == null) {
 			throw new FileNotFoundException("File " + fromFile +
 					" does not exist in the JAR package.");
 		}
 
-		BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+		BufferedReader reader = new BufferedReader(new java.io.InputStreamReader(is));
 		FileWriter writer = new FileWriter(toFile, false);
 
-		ret = reader.read(cbuf, 0, DEFAULT_BUFSIZE);
-		while(ret > 0){
+		final char[] cbuf = new char[DEFAULT_BUFSIZE];
+		int ret = reader.read(cbuf, 0, DEFAULT_BUFSIZE);
+		while (ret > 0) {
 			writer.write(cbuf, 0, ret);
 			ret = reader.read(cbuf, 0, DEFAULT_BUFSIZE);
 		}