Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. try (FileOutputStream fos = new FileOutputStream("C://file/2.txt");)
  2. {
  3. BufferedInputStream bis = new BufferedInputStream(sin);
  4. BufferedOutputStream bos = new BufferedOutputStream(fos);
  5. int n;
  6. int length = 16;//известна, задается извне
  7. byte[] buffer = new byte[8192];
  8. while (((n = bis.read(buffer)) > -1) && (length > 0)) {
  9. if (n > length) n = length;
  10. length -= n;
  11. bos.write(buffer, 0, n);
  12. bos.flush();
  13. // out.flush();
  14. }
  15.  
  16. } catch (IOException ex) {
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement