Gzip の解凍で問題に直面しています。
状況はこんな感じです。UTF-8 形式のテキストがあります。このテキストは、PHP の gzdeflate() 関数を使用して圧縮され、Mysql の blob オブジェクトに保存されます。
ここで、blob オブジェクトを取得しようとし、Java の Gzip Stream を使用して圧縮を解除しました。しかし、GZIP 形式ではないというエラーがスローされます。
Java で Inflater を使用して同じことを行いましたが、「DataFormatException: ヘッダー チェックが正しくありません」というメッセージが表示されます。インフレータのコードは次のとおりです。
//rs is the resultset
//blobAsBytes is the byte array
while(rs.next()){
blob = rs.getBlob("old_text");
int blobLength = (int) blob.length();
blobAsBytes = blob.getBytes(1, blobLength);
}
Inflater decompresser = new Inflater();
decompresser.setInput(blobAsBytes);
byte[] result = new byte[100];
int resultLength = decompresser.inflate(result); // this is the line where the exception is occurring.
decompresser.end();
// Decode the bytes into a String
String outputString = new String(result, 0, resultLength, "UTF-8");
System.out.println(outputString);
Java を使用してこれを行い、データベースに保存されているすべてのテキストを取得する必要があります。
誰かがこれで私を助けてくれませんか。