2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.0b1)
3 * Copyright (C) 2014 The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
17 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 import jalview.datamodel.Alignment;
22 import jalview.io.AppletFormatAdapter;
23 import jalview.io.FileParse;
25 import java.applet.Applet;
26 import java.io.InputStream;
28 public class JalviewLiteURLRetrieve extends Applet
31 private static final long serialVersionUID = 1L;
34 * This is the default constructor
36 public JalviewLiteURLRetrieve()
42 * This method initializes this
48 this.setSize(300, 200);
49 String file = getParameter("file");
53 .println("Specify a resource to read on the file parameter");
56 String protocol = null;
59 System.out.println("Loading thread started with:\n>>file\n" + file
61 // This might throw a security exception in certain browsers
62 // Netscape Communicator for instance.
66 InputStream is = getClass().getResourceAsStream("/" + file);
72 System.err.println("Resource '" + file + "' was "
73 + (rtn ? "" : "not") + " located by classloader.");
76 protocol = AppletFormatAdapter.CLASSLOADER;
79 } catch (Exception ex)
81 System.out.println("Exception checking resources: " + file + " "
84 if (file.indexOf("://") > -1)
86 protocol = AppletFormatAdapter.URL;
90 // skipping codebase prepend check.
91 protocol = AppletFormatAdapter.FILE;
94 System.out.println("Trying to get contents of resource:");
95 FileParse fp = new FileParse(file, protocol);
99 while ((ln = fp.nextLine()) != null)
101 System.out.print(ln);
107 System.out.println("Resource at " + file
108 + " cannot be read with protocol==" + protocol);
111 String format = getParameter("format");
112 if (format == null || format.length() == 0)
114 format = new jalview.io.IdentifyFile().Identify(file, protocol);
115 System.out.println("Format is " + format);
119 System.out.println("User specified Format is " + format);
124 al = new AppletFormatAdapter().readFile(file, protocol, format);
125 } catch (java.io.IOException ex)
127 System.err.println("Failed to open the file.");
128 ex.printStackTrace();
132 System.out.println(new AppletFormatAdapter().formatSequences(
133 "FASTA", al, false));
135 } catch (Exception e)
137 System.err.println("bailing out : Unexpected exception:");