How to get bytes from audio file in blackberry. I used file picker and uploaded the audio. I tried this -
FileConnection fc= (FileConnection)Connector.open(sel);
InputStream is=fc.openInputStream();
ReimgData = IOUtilities.streamToBytes(is);
i have to use any encoding methods ?.
On image encoding, we use the following code for encoding
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());