/* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
+ * Copyright (c) 1999-2001 Xerox Corporation,
* 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Xerox/PARC initial implementation
+ * All rights reserved.
+ * This program and the accompanying materials are made available
+ * under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Xerox/PARC initial implementation
* ******************************************************************/
package org.aspectj.util;
/** @return true if file exists and is a zip file */
public static boolean isZipFile(File file) {
- try {
- return (null != file) && new ZipFile(file) != null;
+ if (file == null)
+ return false;
+ try (ZipFile zipFile = new ZipFile(file)) {
+ return true;
} catch (IOException e) {
return false;
}
}
try {
File f = new File(path);
-
+
if (f.exists() && f.canRead()) {
if (mustBeJar && !f.isDirectory()) {
result = FileUtil.getBestFile(f);
* @throws IOException
*/
public static void copyValidFiles(File fromFile, File toFile) throws IOException {
- FileInputStream in = null;
- FileOutputStream out = null;
- try {
- in = new FileInputStream(fromFile);
- out = new FileOutputStream(toFile);
+ try (FileInputStream in = new FileInputStream(fromFile); FileOutputStream out = new FileOutputStream(toFile)){
copyStream(in, out);
- } finally {
- if (out != null) {
- out.close();
- }
- if (in != null) {
- in.close();
- }
}
}