-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFileOperations.java
executable file
·47 lines (41 loc) · 1.4 KB
/
FileOperations.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import java.io.*;
public class FileOperations {
public FileOperations() {
}
public static final byte[] ReadFile(String s) {
try {
File file = new File(s);
int i = (int)file.length();
byte abyte0[] = new byte[i];
DataInputStream datainputstream = new DataInputStream(new BufferedInputStream(new FileInputStream(s)));
datainputstream.readFully(abyte0, 0, i);
datainputstream.close();
TotalRead++;
return abyte0;
} catch(Exception exception) {
}
return null;
}
public static final void WriteFile(String s, byte abyte0[]) {
try {
(new File((new File(s)).getParent())).mkdirs();
FileOutputStream fileoutputstream = new FileOutputStream(s);
fileoutputstream.write(abyte0, 0, abyte0.length);
fileoutputstream.close();
TotalWrite++;
CompleteWrite++;
} catch(Throwable throwable) {
System.out.println((new StringBuilder()).append("Write Error: ").append(s).toString());
}
}
public static boolean FileExists(String file) {
File f = new File(file);
if(f.exists())
return true;
else
return false;
}
public static int TotalRead = 0;
public static int TotalWrite = 0;
public static int CompleteWrite = 0;
}