Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Log.d(LOG_TAG, "fileUriString = " + fileUriString);
- Uri tempuri = Uri.parse(fileUriString);
- InputStream is = cR.openInputStream(tempuri);
- String str=is.toString();
- byte[] b3=str.getBytes();
- Log.d(LOG_TAG, "len of data is " + imageByteArray.length
- + " bytes");
- public byte[] readBytes(InputStream inputStream) throws IOException {
- // this dynamically extends to take the bytes you read
- ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream();
- // this is storage overwritten on each iteration with bytes
- int bufferSize = 1024;
- byte[] buffer = new byte[bufferSize];
- // we need to know how may bytes were read to write them to the byteBuffer
- int len = 0;
- while ((len = inputStream.read(buffer)) != -1) {
- byteBuffer.write(buffer, 0, len);
- }
- // and then we can return your byte array.
- return byteBuffer.toByteArray();
- }
- byte[] recordData = IOUtils.toByteArray(inStream);
- while ((len = inputStream.read(buffer)) != -1)
- while (inputStream.available() >0 && (len = inputStream.read(buffer)) != -1)
- InputStream is = ...;
- byte[] bytes = ByteStream.toByteArray(is);
- private static byte[] getStringFromInputStream(InputStream is)
- {
- BufferedReader br = null;
- StringBuilder sb = new StringBuilder();
- byte[] bReturn = new byte[0];
- String line;
- try
- {
- br = new BufferedReader(new InputStreamReader(is, "Big5"));
- while ((line = br.readLine()) != null)
- {
- sb.append(line);
- }
- String sContent = sb.toString();
- bReturn = sContent.getBytes();
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- finally
- {
- if (br != null)
- {
- try
- {
- br.close();
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- }
- }
- return bReturn;
- }
- InputStream is=getContentResolver().openInputStream(uri);
- InputStreamReader ir=new InputStreamReader(is);
- bu=new BufferedReader(ir);
- String s;
- while ((s=bu.readLine())!=null){
- //do something with the line...
- }
- bu.close();
Add Comment
Please, Sign In to add comment