拆分模块
This commit is contained in:
48
FixPackageNames.java
Normal file
48
FixPackageNames.java
Normal file
@@ -0,0 +1,48 @@
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public class FixPackageNames {
|
||||
public static void main(String[] args) {
|
||||
String rootDir = "d:/idea-workspace/Contract-Manager/server/src/main/java";
|
||||
AtomicInteger counter = new AtomicInteger(0);
|
||||
|
||||
try {
|
||||
Path path = Paths.get(rootDir);
|
||||
// System.out.println(path.getFileName().toString());
|
||||
|
||||
Files.walkFileTree(path, new SimpleFileVisitor<Path>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||
// System.out.println(file.toString());
|
||||
if (file.toString().endsWith(".java")) {
|
||||
String content = new String(Files.readAllBytes(file));
|
||||
// System.out.println(content);
|
||||
if (content.indexOf("package com.ecep.contract.manager") >= 0) {
|
||||
System.out.println(content);
|
||||
}
|
||||
|
||||
String newContent = content
|
||||
.replace("package com.ecep.contract.manager", "package com.ecep.contract")
|
||||
.replace("import com.ecep.contract.manager", "import com.ecep.contract");
|
||||
if (!content.equals(newContent)) {
|
||||
Files.write(file, newContent.getBytes());
|
||||
System.out.println("Fixed: " + file.toString());
|
||||
counter.incrementAndGet();
|
||||
}
|
||||
}
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
});
|
||||
|
||||
System.out.println("Total files fixed: " + counter.get());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user