Logo Search packages:      
Sourcecode: wims version File versions

synchronized void ptolemy::plot::PlotBox::parseFile ( String  filespec,
URL  documentBase 
) [inline]

Open up the input file, which could be stdin, a URL, or a file.

Deprecated:
This method is deprecated. Use read() instead.

Reimplemented in ptolemy::plot::Plot.

Definition at line 945 of file PlotBox.java.

References _documentBase, and _parseLine().

                                                                          {
        DataInputStream in = null;

        if ((filespec == null) || (filespec.length() == 0)) {
            // Open up stdin
            in = new DataInputStream(System.in);
        } else {
            try {
                URL url = null;

                if ((documentBase == null) && (_documentBase != null)) {
                    documentBase = _documentBase;
                }

                if (documentBase == null) {
                    url = new URL(filespec);
                } else {
                    try {
                        url = new URL(documentBase, filespec);
                    } catch (NullPointerException e) {
                        // If we got a NullPointerException, then perhaps we
                        // are calling this as an application, not as an applet
                        url = new URL(filespec);
                    }
                }

                in = new DataInputStream(url.openStream());
            } catch (MalformedURLException e) {
                try {
                    // Just try to open it as a file.
                    in = new DataInputStream(new FileInputStream(filespec));
                } catch (FileNotFoundException me) {
                    _errorMsg = new String[2];
                    _errorMsg[0] = "File not found: " + filespec;
                    _errorMsg[1] = me.getMessage();
                    return;
                } catch (SecurityException me) {
                    _errorMsg = new String[2];
                    _errorMsg[0] = "Security Exception: " + filespec;
                    _errorMsg[1] = me.getMessage();
                    return;
                }
            } catch (IOException ioe) {
                _errorMsg = new String[3];
                _errorMsg[0] = "Failure opening URL: ";
                _errorMsg[1] = " " + filespec;
                _errorMsg[2] = ioe.getMessage();
                return;
            }
        }

        // At this point, we've opened the data source, now read it in
        try {
            BufferedReader din = new BufferedReader(new InputStreamReader(in));
            String line = din.readLine();

            while (line != null) {
                _parseLine(line);
                line = din.readLine();
            }
        } catch (MalformedURLException e) {
            _errorMsg = new String[2];
            _errorMsg[0] = "Malformed URL: " + filespec;
            _errorMsg[1] = e.getMessage();
            return;
        } catch (IOException e) {
            _errorMsg = new String[2];
            _errorMsg[0] = "Failure reading data: " + filespec;
            _errorMsg[1] = e.getMessage();
            _errorMsg[1] = e.getMessage();
        } finally {
            try {
                in.close();
            } catch (IOException me) {
            }
        }
    }


Generated by  Doxygen 1.6.0   Back to index