Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try (FileOutputStream fos = new FileOutputStream("C://file/2.txt");)
- {
- BufferedInputStream bis = new BufferedInputStream(sin);
- BufferedOutputStream bos = new BufferedOutputStream(fos);
- int n;
- int length = 16;//известна, задается извне
- byte[] buffer = new byte[8192];
- while (((n = bis.read(buffer)) > -1) && (length > 0)) {
- if (n > length) n = length;
- length -= n;
- bos.write(buffer, 0, n);
- bos.flush();
- // out.flush();
- }
- } catch (IOException ex) {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement