/UniversalImageLoader/src/com/nostra13/universalimageloader/utils/FileUtils.java

https://github.com/rashedulkabir/Android-Universal-Image-Loader · Java · 29 lines · 19 code · 5 blank · 5 comment · 3 complexity · a67d538ce19e47aac5715580fc8f1b80 MD5 · raw file

  1. package com.nostra13.universalimageloader.utils;
  2. import java.io.IOException;
  3. import java.io.InputStream;
  4. import java.io.OutputStream;
  5. /**
  6. * Provides operations with files
  7. *
  8. * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
  9. */
  10. public final class FileUtils {
  11. private static final int BUFFER_SIZE = 8 * 1024; // 8 KB
  12. private FileUtils() {
  13. }
  14. public static void copyStream(InputStream is, OutputStream os) throws IOException {
  15. byte[] bytes = new byte[BUFFER_SIZE];
  16. while (true) {
  17. int count = is.read(bytes, 0, BUFFER_SIZE);
  18. if (count == -1) {
  19. break;
  20. }
  21. os.write(bytes, 0, count);
  22. }
  23. }
  24. }