Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. public void onClick(View v) {
  2. WebServiceC webService = WebServiceC();
  3.  
  4. epubDownloaded = webService.downloadEpub(publi.getId());
  5. File fileEpub=new File(Environment.getExternalStorageDirectory(), "test.epub");
  6. if (fileEpub.exists()) {
  7. fileEpub.delete();
  8. }
  9. try {
  10. FileOutputStream fos=new FileOutputStream(arquivoEpub.getPath());
  11.  
  12. fos.write(epubDownloaded);
  13. fos.close();
  14. }catch (IOException e) {
  15. e.printStackTrace();
  16. }
  17. }
  18.  
  19. });
  20.  
  21. int count;
  22. WebServiceC webService = new WebServiceC();
  23.  
  24. epubDownloaded = webService.downloadEpub(publi.getId());
  25.  
  26. InputStream input = new ByteArrayInputStream(epubDownloaded);
  27. OutputStream output = null;
  28. try {
  29. output = new FileOutputStream(Environment.getExternalStorageDirectory()+"/test.epub");
  30. } catch (FileNotFoundException e) {
  31. e.printStackTrace();
  32. }
  33. byte data[] = new byte[1024];
  34.  
  35. try {
  36. while ((count = input.read(data)) != -1) {
  37.  
  38. output.write(data, 0, count);
  39. }
  40. } catch (IOException e) {
  41. // TODO Auto-generated catch block
  42. e.printStackTrace();
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement