X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FFileParse.java;h=7e1940fe0b1ca18b14e313bb1a2c00aae6d6be4c;hb=5969ead0fd401f4435a3435ede9e4e87cf9c1d0b;hp=bf0a844845c380f0577955b47a89d849b1844c9c;hpb=8875ec9fa2dcd7dcb494a1538ae61e3279ceb4aa;p=jalview.git diff --git a/src/jalview/io/FileParse.java b/src/jalview/io/FileParse.java index bf0a844..7e1940f 100755 --- a/src/jalview/io/FileParse.java +++ b/src/jalview/io/FileParse.java @@ -58,6 +58,8 @@ public class FileParse public File inFile = null; + public byte[] bytes; // from JavaScript + /** * a viewport associated with the current file operation. May be null. May * move to different object. @@ -315,12 +317,41 @@ public class FileParse public FileParse(String fileStr, DataSourceType sourceType) throws MalformedURLException, IOException { + + this(null, fileStr, sourceType, false); + } + + public FileParse(File file, DataSourceType sourceType) + throws MalformedURLException, IOException + { + + this(file, file.getPath(), sourceType, true); + } + + private FileParse(File file, String fileStr, DataSourceType sourceType, + boolean isFileObject) throws MalformedURLException, IOException + { + + /** + * @j2sNative + * + * this.bytes = file && file._bytes; + * + */ this.dataSourceType = sourceType; error = false; if (sourceType == DataSourceType.FILE) { - if (checkFileSource(fileStr)) + + if (bytes != null) + { + // this will be from JavaScript + inFile = file; + dataIn = new BufferedReader(new StringReader(new String(bytes))); + dataName = fileStr; + } + else if (checkFileSource(fileStr)) { String suffixLess = extractSuffix(fileStr); if (suffixLess != null) @@ -434,7 +465,8 @@ public class FileParse { // pass up the reason why we have no source to read from throw new IOException(MessageManager.formatMessage( - "exception.failed_to_read_data_from_source", new String[] + "exception.failed_to_read_data_from_source", + new String[] { errormessage })); } error = false;