-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMergeQuickFix.java
More file actions
43 lines (41 loc) · 1.12 KB
/
Copy pathMergeQuickFix.java
File metadata and controls
43 lines (41 loc) · 1.12 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
import java.io.File;
import java.io.IOException;
import java.util.Scanner;
import java.util.ArrayList;
import java.io.PrintWriter;
public class MergeQuickFix {
public static void main(String... pumpkins) {
for (File file : FileSearcher.findFiles(FileSearcher.CURRENT_FOLDER, "java", "txt")) {
if (file.getName().contains("MergeQuickFix")) continue;
boolean changed = false;
ArrayList<String> fileContents = new ArrayList<String>();
Scanner input = null;
try {
input = new Scanner(file);
} catch (IOException e) {
continue;
}
while (input.hasNext()) {
String nextLine = input.nextLine();
if (!nextLine.contains("=====") && !nextLine.contains(">>>>>") && !nextLine.contains("<<<<<"))
fileContents.add(nextLine);
else changed = true;
}
input.close();
if (!changed) {
System.out.println("Checked: " + file);
continue;
}
PrintWriter writer = null;
try {
writer = new PrintWriter(file);
} catch (IOException e) {
continue;
}
for (String line : fileContents)
writer.println(line);
writer.close();
System.out.println("Fixed: " + file);
}
}
}