Friday, April 20, 2012

Get the Byte from by any file.



public static byte[] returnByte(String path)
{
FileConnection fconn;
int available = 0;
InputStream input = null;
byte[] data=null;
try
{
fconn = (FileConnection)Connector.open(path);
if(fconn.exists()==true)
{
input = fconn.openInputStream();
available = input.available();
int fSz = (int)fconn.fileSize();
data = new byte[fSz];
input.read(data, 0, fSz);
}
}
catch(Exception e)
{
Dialog.alert("Error");
}
return data;
}

No comments:

Post a Comment