2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 public class FileParse
27 protected String type;
28 protected BufferedReader dataIn;
34 public FileParse(String fileStr, String type)
35 throws MalformedURLException, IOException
39 if (type.equals(AppletFormatAdapter.FILE))
41 this.inFile = new File(fileStr);
42 dataIn = new BufferedReader(new FileReader(fileStr));
44 else if (type.equals(AppletFormatAdapter.URL))
46 URL url = new URL(fileStr);
47 dataIn = new BufferedReader(new InputStreamReader(url.openStream()));
49 else if (type.equals(AppletFormatAdapter.PASTE))
51 dataIn = new BufferedReader(new StringReader(fileStr));
53 else if (type.equals(AppletFormatAdapter.CLASSLOADER))
55 java.io.InputStream is = getClass().getResourceAsStream("/" + fileStr);
58 dataIn = new BufferedReader(new java.io.InputStreamReader(is));
63 public String nextLine()
66 return dataIn.readLine();