-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetIDs.java
More file actions
38 lines (32 loc) · 842 Bytes
/
Copy pathGetIDs.java
File metadata and controls
38 lines (32 loc) · 842 Bytes
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
import java.util.*;
import java.io.*;
public class GetIDs {
public static String returnID(String filename) {
File f = new File(filename);
int count = 0;
String countString;
if(f.exists()) {
count = countLines(filename);
count += 1;
} else {
count += 1;
}
countString = Integer.toString(count);
}
public static int countLines(String filename) {
int count = 0;
File f = new File(filename);
try {
Scanner sc = new Scanner(f);
while(sc.hasNextLine()) {
sc.nextLine();
count++;
}
sc.close();
return count;
} catch (Exception e){
e.getStackTrace();
return -1;
}
}
}