-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDriveFile.java
More file actions
45 lines (40 loc) · 1.07 KB
/
DriveFile.java
File metadata and controls
45 lines (40 loc) · 1.07 KB
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
import java.util.ArrayList;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.lang.Runtime;
import java.lang.Process;
import java.io.BufferedReader;
import java.io.IOException;
public class DriveFile
{
String name;
String md5sum;
String fid;
public DriveFile()
{
name="";
md5sum="";
fid="";
}
public static DriveFile isIn(ArrayList<DriveFile> ls, String f)
{
for(int i=0; i<ls.size(); i++)
{
if(ls.get(i).name.equals(f))
{
return ls.get(i);
}
}
return null;
}
public static String getMdSum(String f) throws IOException
{
Runtime r=Runtime.getRuntime();
Process p=r.exec("md5sum "+f);
InputStream in=p.getInputStream();
BufferedReader reader=new BufferedReader(new InputStreamReader(in));
StringBuilder code=new StringBuilder();
code.append(reader.readLine());
return code.toString().substring(0,(code.toString().indexOf(' ')));
}
}