Skip to content

Commit

Permalink
[pulsar-io] Remove unused annotation (apache#4303)
Browse files Browse the repository at this point in the history
* Remove unused annotation

* Use try-resource management
  • Loading branch information
liketic authored and merlimat committed May 21, 2019
1 parent 4d9351d commit f0a33c4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public class GZipFiles {
/**
* Returns true if the given file is a gzip file.
*/
@SuppressWarnings("deprecation")
public static boolean isGzip(File f) {
public static boolean isGzip(File f) {

InputStream input = null;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,13 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.stream.Stream;
import java.util.zip.ZipInputStream;

import org.apache.commons.io.IOUtils;

/**
* Helper class that provides helper methods for working with
* zip-formatted files.
Expand All @@ -44,19 +41,12 @@ public class ZipFiles {
/**
* Returns true if the given file is a gzip file.
*/
@SuppressWarnings("deprecation")
public static boolean isZip(File f) {

InputStream input = null;
try {
DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(f)));
public static boolean isZip(File f) {
try (DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(f)))){
int test = in.readInt();
in.close();
return test == 0x504b0304;
} catch (final Exception e) {
return false;
} finally {
IOUtils.closeQuietly(input);
}
}

Expand Down

0 comments on commit f0a33c4

Please sign in to comment.