X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FFileParse.java;h=46f223a9fe3b1b24360b021b1275fcf31ae6e3cb;hb=d587f1aa61946dc14f6f089cf1dc2a3116cfb773;hp=af3bbeca10db20c4b1f5fa044a8d78089d517ab0;hpb=efc31b4a8d5cee63555586804a2b79c06bdb5a14;p=jalview.git diff --git a/src/jalview/io/FileParse.java b/src/jalview/io/FileParse.java index af3bbec..46f223a 100755 --- a/src/jalview/io/FileParse.java +++ b/src/jalview/io/FileParse.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -24,8 +24,6 @@ import java.net.*; public class FileParse { public File inFile; - public int fileSize; - public int noLines; protected String type; protected BufferedReader dataIn; @@ -38,35 +36,33 @@ public class FileParse { this.type = type; - if (type.equals("File")) + if (type.equals(AppletFormatAdapter.FILE)) { this.inFile = new File(fileStr); - this.fileSize = (int) inFile.length(); - dataIn = new BufferedReader(new FileReader(fileStr)); } - else if (type.equals("URL")) + else if (type.equals(AppletFormatAdapter.URL)) { URL url = new URL(fileStr); - this.fileSize = 0; dataIn = new BufferedReader(new InputStreamReader(url.openStream())); } - else if (type.equals("Paste")) + else if (type.equals(AppletFormatAdapter.PASTE)) { dataIn = new BufferedReader(new StringReader(fileStr)); } + else if (type.equals(AppletFormatAdapter.CLASSLOADER)) + { + java.io.InputStream is = getClass().getResourceAsStream("/" + fileStr); + if (is != null) + { + dataIn = new BufferedReader(new java.io.InputStreamReader(is)); + } + } } public String nextLine() throws IOException { - String next = dataIn.readLine(); - - if (next != null) - { - noLines++; - } - - return next; + return dataIn.readLine(); } }