ブラックベリーのオーディオファイルからバイトを取得する方法。ファイルピッカーを使用してオーディオをアップロードしました。私はこれを試しました-
FileConnection fc= (FileConnection)Connector.open(sel);
InputStream is=fc.openInputStream();
ReimgData = IOUtilities.streamToBytes(is);
私は任意のエンコード方法を使用する必要がありますか?
画像のエンコードでは、エンコードに次のコードを使用します
EncodedImage encode_image =EncodedImage.createEncodedImage(ReimgData, 0, (int)fc.fileSize());
JPEGEncodedImage encoder=JPEGEncodedImage.encode(encode_image.getBitmap(),50);
byte[] array=encoder.getData();
// Decodes the image represented by this EncodedImage and returns a Bitmap
int length=array.length;
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(length);
Base64OutputStream base64OutputStream = new Base64OutputStream( byteArrayOutputStream );
try{
base64OutputStream.write( array, 0, length );
base64OutputStream.flush();
base64OutputStream.close();
}
catch (IOException ioe){
//Dialog.alert("Error in encodeBase64() : "+ioe.toString());
System.out.println("Error in encodeBase64() : "+ioe.toString());
}
//----Decoding image
try
{
System.out.print(byteArrayOutputStream.toString());
//Dialog.alert(byteArrayOutputStream.toString()+"");
data = Base64InputStream.decode(byteArrayOutputStream.toString());