Ejemplo n.º 1
0
 /**
  * Writes the content of the internal ByteArrayInputStream to the given <code>OutputStream</code>.
  *
  * <p>Behaves like: <code>
  * os.write(content.getByteArray());
  * </code>
  *
  * @param os The <code>OutputStream</code> to write to.
  */
 @Override
 public void streamContent(OutputStream os) {
   try {
     // vllt mit Streamer.stream arbeiten?
     // os.write(content.toByteArray());
     ByteArrayInputStream bais = new ByteArrayInputStream(content.toByteArray());
     Streamer.stream(bais, os, UTF8SharkOutputStream.STREAM_BUFFER_SIZE, content.size());
   } catch (IOException ex) {
     L.e(ex.getMessage(), this);
   }
 }
Ejemplo n.º 2
0
  @Override
  public void streamContent(OutputStream os) {

    Statement statement = null;
    try {
      StringBuilder sqlString = new StringBuilder("SELECT content FROM ");
      sqlString.append(SQLSharkKB.INFORMATION_TABLE);
      sqlString.append(" WHERE id = ");
      sqlString.append(this.id);

      Connection conn = this.kb.getConnection();
      statement = this.kb.getConnection().createStatement();

      ResultSet result = statement.executeQuery(sqlString.toString());

      while (result.next()) {
        InputStream is = result.getBinaryStream(1);
        if (is != null) {
          Streamer.stream(is, os, SQLSharkKB.MAX_BUFFER_SIZE);
        }
      }
      result.close();

    } catch (SQLException e) {
      L.e("error while creating SQL-statement: " + e.getLocalizedMessage(), this);
    } catch (IOException ex) {
      L.e("error while streaming content: " + ex.getLocalizedMessage(), this);
    } finally {
      if (statement != null) {
        try {
          statement.close();
        } catch (SQLException ex) {
          // ignore
        }
      }
    }
  }