@@ -14,47 +14,21 @@ public class FileUtils {
14
14
*/
15
15
public static boolean isInputBGZ (final File file ) {
16
16
17
- //.vcf.bgz is type of GZP file
18
- //.vcf.gz is also GZP file but get java.lang.OutOfMemoryError at java.io.InputStreamReader.read(InputStreamReader.java:184)
19
- //.vcf.bz2 is not GZP file and get java.lang.OutOfMemoryError at java.io.InputStreamReader.read(InputStreamReader.java:184)
20
- //.vcf is not GZP file and get htsjdk.samtools.SAMFormatException: at header from java.io.BufferedReader.readLine(BufferedReader.java:389)
21
-
22
- boolean isGzip = false ;
23
- try {
24
- isGzip = isInputGZip (file ); //ture if .bgz or .gz
25
- } catch (IOException e ) {}
26
-
27
-
28
- //if not gzip file, do following check
29
- if (isGzip ) {
30
-
31
- try (BufferedInputStream bufferedInputStream = new BufferedInputStream (new FileInputStream (file ))) {
32
- bufferedInputStream .mark (100 ); // mark the current position
33
- boolean isValid = BlockCompressedInputStream .isValidFile (bufferedInputStream );
34
- bufferedInputStream .reset (); // reset back to the marked position
35
- return isValid ;
36
- } catch (IOException e ) {
37
- // Handle the exception
38
- return false ;
39
- }
40
-
41
- // try(final BlockCompressedInputStream bgzInputStream = new BlockCompressedInputStream(file)) {
42
- // System.out.println(" inside try block: start bufferReader ...");
43
- // BufferedReader reader = new BufferedReader(new InputStreamReader(bgzInputStream));
44
- // System.out.println(" inside try block: reader.readLine()... ");
45
- // String line = reader.readLine();
46
- // return line != null && !line.isEmpty();
47
- // } catch (Exception e) {
48
- // //file is not .vcf.bgz file
49
- // //it will throw any type exception according to file type
50
- // //hence we try to catch any type exception
51
- // e.printStackTrace();
52
- // return false;
53
- // }
54
- }
55
-
56
- return false ;
57
-
17
+ /**
18
+ * .vcf.bgz is type of GZP file
19
+ * .vcf.gz is also GZP file but get java.lang.OutOfMemoryError at java.io.InputStreamReader.read(InputStreamReader.java:184)
20
+ * .vcf.bz2 is not GZP file and get java.lang.OutOfMemoryError at java.io.InputStreamReader.read(InputStreamReader.java:184)
21
+ * .vcf is not GZP file and get htsjdk.samtools.SAMFormatException: at header from java.io.BufferedReader.readLine(BufferedReader.java:389)
22
+ */
23
+ try (BufferedInputStream bufferedInputStream = new BufferedInputStream (new FileInputStream (file ))) {
24
+ bufferedInputStream .mark (100 ); // mark the current position
25
+ boolean isValid = BlockCompressedInputStream .isValidFile (bufferedInputStream );
26
+ bufferedInputStream .reset (); // reset back to the marked position
27
+ return isValid ;
28
+ } catch (IOException e ) {
29
+ // Handle the exception
30
+ return false ;
31
+ }
58
32
}
59
33
60
34
/**
0 commit comments