【初心者】Java質問・相談スレッド88【大歓迎】
■ このスレッドは過去ログ倉庫に格納されています
0074デフォルトの名無しさん
2006/07/27(木) 09:57:52Inflaterクラスで解凍し、Stringとして返す関数を作っているのですが
Inflater.inflateメソッドで解凍された情報を確保する為のbyte配列(byte []result)は
あらかじめ適当なサイズで初期化して確保しておくしかないのでしょうか?
できれば動的にサイズを確保したいのですが・・・。
以下が現在のソースです。
final int maxBufSize = 100000;
public String decompressString(byte[] input)
{
//Decompress the bytes
Inflater inf = new Inflater();
inf.setInput(input);
byte[] result = new byte[maxBufSize];
int resultLength;
try{
resultLength = inf.inflate(result);
}catch(Exception e){
return null; }
inf.end();
//Decode the bytes into a String
String outputString;
try{
outputString = new String(result,0,resultLength,"UTF-8");
}catch(Exception e){
return null; }
return outputString;
}
■ このスレッドは過去ログ倉庫に格納されています