From 4470f70edde045b7d649faaa0e446d57f3d31fa6 Mon Sep 17 00:00:00 2001 From: Michael Genereux Date: Tue, 4 Oct 2022 10:03:05 -0700 Subject: [PATCH] File detection update File type detection is different under newer versions of Java and this adds support for null detection and alternate MIME strings. --- uk/ac/babraham/FastQC/Sequence/FastQFile.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/uk/ac/babraham/FastQC/Sequence/FastQFile.java b/uk/ac/babraham/FastQC/Sequence/FastQFile.java index 6c34e6c..8c84de1 100644 --- a/uk/ac/babraham/FastQC/Sequence/FastQFile.java +++ b/uk/ac/babraham/FastQC/Sequence/FastQFile.java @@ -77,17 +77,18 @@ protected FastQFile(FastQCConfig config,File file) throws SequenceFormatExceptio } System.out.println(file.toPath()); - System.out.println(Files.probeContentType(file.toPath())); - + + String content_type = Files.probeContentType(file.toPath()); + System.out.println(content_type); + if (file.getName().startsWith("stdin")) { br = new BufferedReader(new InputStreamReader(System.in)); - } - else if (Files.probeContentType(file.toPath()).equals("application/x-gzip")) { + } else if (content_type != null + && (content_type.equals("application/x-gzip") || content_type.equals("application/gzip"))) { br = new BufferedReader(new InputStreamReader(new MultiMemberGZIPInputStream(fis))); - } - else if (file.getName().toLowerCase().endsWith(".bz2")) { - br = new BufferedReader(new InputStreamReader(new BZip2InputStream(fis,false))); - } + } else if (file.getName().toLowerCase().endsWith(".bz2")) { + br = new BufferedReader(new InputStreamReader(new BZip2InputStream(fis, false))); + } else { br = new BufferedReader(new InputStreamReader(fis));