X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FFileParse.java;h=69c362ffb5916d7c512df98c3eaa9721e1fb964f;hb=5d59bb58f5bcecc6b240d125e13bbe1f1868f681;hp=d20b4681c298f9392a6ba18ddf045ad14e6d4b87;hpb=7ab5d6b0ba5fec1ea4a4239e79c476d841622485;p=jalview.git diff --git a/src/jalview/io/FileParse.java b/src/jalview/io/FileParse.java index d20b468..69c362f 100755 --- a/src/jalview/io/FileParse.java +++ b/src/jalview/io/FileParse.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) - * Copyright (C) 2014 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * @@ -20,8 +20,19 @@ */ package jalview.io; -import java.io.*; -import java.net.*; +import jalview.util.MessageManager; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.StringReader; +import java.net.MalformedURLException; +import java.net.URL; import java.util.zip.GZIPInputStream; /** @@ -50,7 +61,7 @@ public class FileParse public void setNewlineString(String nl) { - newline = nl; + newline = nl; } public String getNewlineString() @@ -94,11 +105,12 @@ public class FileParse { if (from == null) { - throw new Error( - "Implementation error. Null FileParse in copy constructor"); + throw new Error(MessageManager.getString("error.implementation_error_null_fileparse")); } if (from == this) + { return; + } index = ++from.index; inFile = from.inFile; suffixSeparator = from.suffixSeparator; @@ -156,7 +168,7 @@ public class FileParse { warningMessage = "Failed to resolve as a GZ stream (" + x.getMessage() + ")"; - x.printStackTrace(); + // x.printStackTrace(); } ; } @@ -208,7 +220,7 @@ public class FileParse { if (e != null) { - throw new IOException("Failed to resolve GZIP stream", e); + throw new IOException(MessageManager.getString("exception.failed_to_resolve_gzip_stream"), e); } throw q; } @@ -263,14 +275,12 @@ public class FileParse { if (checkFileSource(suffixLess)) { - throw new IOException("Problem opening " + inFile - + " (also tried " + suffixLess + ") : " + errormessage); + throw new IOException(MessageManager.formatMessage("exception.problem_opening_file_also_tried", new String[]{inFile.getName(),suffixLess,errormessage})); } } else { - throw new IOException("Problem opening " + inFile + " : " - + errormessage); + throw new IOException(MessageManager.formatMessage("exception.problem_opening_file", new String[]{inFile.getName(),errormessage})); } } } @@ -282,7 +292,9 @@ public class FileParse { checkURLSource(fileStr); if (suffixSeparator == '#') + { extractSuffix(fileStr); // URL lref is stored for later reference. + } } catch (IOException e) { String suffixLess = extractSuffix(fileStr); @@ -324,7 +336,9 @@ public class FileParse { String suffixLess = extractSuffix(fileStr); if (suffixLess != null) + { is = getClass().getResourceAsStream("/" + suffixLess); + } } if (is != null) { @@ -345,8 +359,7 @@ public class FileParse if (dataIn == null || error) { // pass up the reason why we have no source to read from - throw new IOException("Failed to read data from source:\n" - + errormessage); + throw new IOException(MessageManager.formatMessage("exception.failed_to_read_data_from_source", new String[]{errormessage})); } error = false; dataIn.mark(READAHEAD_LIMIT); @@ -366,15 +379,17 @@ public class FileParse } else { - throw new IOException("Unitialised Source Stream"); + throw new IOException(MessageManager.getString("exception.no_init_source_stream")); } } public String nextLine() throws IOException { if (!error) + { return dataIn.readLine(); - throw new IOException("Invalid Source Stream:" + errormessage); + } + throw new IOException(MessageManager.formatMessage("exception.invalid_source_stream", new String[]{errormessage})); } public boolean isValid() @@ -406,8 +421,7 @@ public class FileParse } else { - throw new IOException( - "Implementation Error: Reset called for invalid source."); + throw new IOException(MessageManager.getString("error.implementation_error_reset_called_for_invalid_source")); } }