Logo 
Search:

Java Answers

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds
  Question Asked By: Anpu Massri   on Apr 01 In Java Category.

  
Question Answered By: Freda Lane   on Apr 01

some code from net
.
.
.

try {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("SELECT col_blob FROM
mysql_all_table");

if (rs.next()) {
// Get the blob  from the result set
Blob blob = rs.getBlob("col_blob");

// Get the number bytes in the BLOB
long blobLength = blob.length();

// Get bytes from the BLOB in a byte array
int pos = 1; // position is 1-based
int len = 10;
byte[] bytes = blob.getBytes(pos, len);

// Get bytes from the BLOB using a stream
InputStream is = blob.getBinaryStream();
int b = is.read();
}
} catch (IOException e) {
} catch (SQLException e) {
}


and this is another code from net


// Create the decompressor and give it the data  to compress
Inflater decompressor = new Inflater();
decompressor.setInput(compressedData);

// Create an expandable byte array to hold the decompressed data
ByteArrayOutputStream bos = new
ByteArrayOutputStream(compressedData.length);

// Decompress the data
byte[] buf = new byte[1024];
while (!decompressor.finished()) {
try {
int count = decompressor.inflate(buf);
bos.write(buf, 0, count);
} catch (DataFormatException e) {
}
}
try {
bos.close();
} catch (IOException e) {
}

// Get the decompressed data
byte[] decompressedData = bos.toByteArray();




so the only thing u 'll have to do to find out how to write a file  using java.
and then make little optimizations on your code... : )

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on problem with Blob data Or get search suggestion and latest updates.


Tagged: