Advertisement
Guest User

Untitled

a guest
Aug 30th, 2014
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. package com.support;
  2. import java.io.*;
  3.  
  4. public class FileOperations {
  5.  
  6. public FileOperations() {
  7. }
  8.  
  9. public static final byte[] ReadFile(String s) {
  10. try {
  11. File file = new File(s);
  12. int i = (int)file.length();
  13. byte abyte0[] = new byte[i];
  14. DataInputStream datainputstream = new DataInputStream(new BufferedInputStream(new FileInputStream(s)));
  15. datainputstream.readFully(abyte0, 0, i);
  16. datainputstream.close();
  17. TotalRead++;
  18. return abyte0;
  19. } catch(Exception exception) {
  20. }
  21. return null;
  22. }
  23.  
  24. public static final void WriteFile(String s, byte abyte0[]) {
  25. try {
  26. (new File((new File(s)).getParent())).mkdirs();
  27. FileOutputStream fileoutputstream = new FileOutputStream(s);
  28. fileoutputstream.write(abyte0, 0, abyte0.length);
  29. fileoutputstream.close();
  30. TotalWrite++;
  31. CompleteWrite++;
  32. } catch(Throwable throwable) {
  33. System.out.println((new StringBuilder()).append("Write Error: ").append(s).toString());
  34. }
  35. }
  36.  
  37. public static boolean FileExists(String file) {
  38. File f = new File(file);
  39. if(f.exists())
  40. return true;
  41. else
  42. return false;
  43. }
  44.  
  45. public static int TotalRead = 0;
  46. public static int TotalWrite = 0;
  47. public static int CompleteWrite = 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement