Exemplo n.º 1
1
  public DBaseFile(InputStream is) {
    if (is == null) {
      String message = Logging.getMessage("nullValue.InputStreamIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    this.file = null;
    try {
      this.header = this.readHeaderFromStream(is);
      this.fields = this.readFieldsFromBuffer(this.header.fieldsHeaderBuffer);
      this.records = this.readRecordsFromStream(is);
    } catch (Exception e) {
      String message = Logging.getMessage("generic.ExceptionAttemptingToReadFrom", is.toString());
      Logging.logger().log(java.util.logging.Level.SEVERE, message, e);
      throw new WWRuntimeException(message, e);
    }
  }
Exemplo n.º 2
0
  protected Header readHeaderFromFile(File file) throws IOException {
    InputStream is = null;
    Header header = null;
    try {
      is = new BufferedInputStream(new FileInputStream(file));
      header = this.readHeaderFromStream(is);
    } finally {
      if (is != null) is.close();
    }

    return header;
  }
Exemplo n.º 3
0
  protected List<DBaseRecord> readRecordsFromFile(File file) throws IOException {
    List<DBaseRecord> records;
    InputStream is = null;

    try {
      is = new BufferedInputStream(new FileInputStream(file));
      WWIO.skipBytes(is, this.header.headerLength); // Skip over header
      records = this.readRecordsFromStream(is);
    } finally {
      if (is != null) is.close();
    }

    return records;
  }
  /**
   * Open and parse the specified file expressed as a file: URL..
   *
   * @param url the URL of the file to open, expressed as a URL with a scheme of "file".
   * @param linkBase the original address of the document if the file is a retrieved and cached
   *     file.
   * @return A {@code ColladaRoot} representing the file's COLLADA contents.
   * @throws IOException if an I/O error occurs during opening and parsing.
   * @throws XMLStreamException if a server parsing error is encountered.
   */
  protected ColladaRoot parseCachedColladaFile(URL url, String linkBase)
      throws IOException, XMLStreamException {
    ColladaDoc colladaDoc;

    InputStream refStream = url.openStream();

    colladaDoc = new ColladaInputStream(refStream, WWIO.makeURI(linkBase));

    try {
      ColladaRoot refRoot = new ColladaRoot(colladaDoc);
      refRoot.parse(); // also closes the URL's stream
      return refRoot;
    } catch (XMLStreamException e) {
      refStream.close(); // parsing failed, so explicitly close the stream
      throw e;
    }
  }