X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FIdentifyFile.java;h=ea870582e3f3f5eef6c3e8a3a39e1f90b20b6791;hb=cadabddd959db11250cdf19b28606106540b3268;hp=5a3d700f74c020e3514295215de1fb9d6e3d91ce;hpb=9d2408483e451285fd555c3cd6e0273977acbaa7;p=jalview.git diff --git a/src/jalview/io/IdentifyFile.java b/src/jalview/io/IdentifyFile.java index 5a3d700..ea87058 100755 --- a/src/jalview/io/IdentifyFile.java +++ b/src/jalview/io/IdentifyFile.java @@ -20,10 +20,11 @@ */ package jalview.io; -import java.util.Locale; - import java.io.File; import java.io.IOException; +import java.util.Locale; + +import jalview.bin.Console; /** * DOCUMENT ME! @@ -33,12 +34,14 @@ import java.io.IOException; */ public class IdentifyFile { - - public FileFormatI identify(Object file, DataSourceType protocol) throws FileFormatException + + public FileFormatI identify(Object file, DataSourceType protocol) + throws FileFormatException { // BH 2018 - return (file instanceof File ? identify((File) file, protocol) : identify((String) file, protocol)); - + return (file instanceof File ? identify((File) file, protocol) + : identify((String) file, protocol)); + } public FileFormatI identify(File file, DataSourceType sourceType) @@ -56,8 +59,7 @@ public class IdentifyFile } } catch (Exception e) { - System.err.println("Error whilst identifying " + file); - e.printStackTrace(System.err); + Console.error("Error whilst identifying " + file, e); emessage = e.getMessage(); } if (parser != null) @@ -92,8 +94,7 @@ public class IdentifyFile } } catch (Exception e) { - System.err.println("Error whilst identifying " + file); - e.printStackTrace(System.err); + Console.error("Error whilst identifying " + file, e); emessage = e.getMessage(); } if (parser != null) @@ -167,8 +168,8 @@ public class IdentifyFile if (source.inFile != null) { String fileStr = source.inFile.getName(); - if (fileStr.contains(".jar") - || fileStr.contains(".zip") || fileStr.contains(".jvp")) + if (fileStr.contains(".jar") || fileStr.contains(".zip") + || fileStr.contains(".jvp")) { // possibly a Jalview archive (but check further) reply = FileFormat.Jalview; @@ -406,16 +407,15 @@ public class IdentifyFile } } catch (Exception ex) { - System.err.println("File Identification failed!\n" + ex); + Console.error("File Identification failed!\n" + ex); throw new FileFormatException(source.errormessage); } if (trimmedLength == 0) { - System.err.println( - "File Identification failed! - Empty file was read."); + Console.error("File Identification failed! - Empty file was read."); throw new FileFormatException("EMPTY DATA FILE"); } - System.out.println("File format identified as " + reply.toString()); + Console.debug("File format identified as " + reply.toString()); return reply; } @@ -483,17 +483,16 @@ public class IdentifyFile type = ider.identify(args[i], DataSourceType.FILE); } catch (FileFormatException e) { - System.err.println( + Console.error( String.format("Error '%s' identifying file type for %s", args[i], e.getMessage())); } - System.out.println("Type of " + args[i] + " is " + type); + Console.debug("Type of " + args[i] + " is " + type); } if (args == null || args.length == 0) { - System.err.println("Usage: [ ...]"); + Console.error("Usage: [ ...]"); } } - }