📄 fileoper.java
字号:
package net.aetherial.gis.output.toLd.repeate;
import java.io.File;
import net.aetherial.gis.output.toLd.OpenDirectory;
import net.aetherial.gis.our.FrameOur;
import net.aetherial.gis.output.toLd.bianma.BmAtRepeate;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2004</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class FileOper {
private String inputPath = "";
private String outputPath = "";
private File[] allSourceFile = null;
private BmAtRepeate bianma = new BmAtRepeate();
public FileOper() {
}
public void scanAllSourceFile(String inputPath){
OpenDirectory od = new OpenDirectory();
this.allSourceFile = od.getOpenFile(inputPath);
this.inputPath = inputPath;
}
public void deleteTargetExistFile(){
File temp = null;
for (int i = 0;this.allSourceFile != null && i <this.allSourceFile .length; i++) {
try {
temp = new File(this.outputPath +
this.getleft(this.allSourceFile[i].getAbsolutePath(),
this.inputPath));
if (temp.exists()) {
System.out.println(" 在目标文件夹里存在同名的文件:" + temp.getAbsolutePath());
temp.delete();
}
}
catch (Exception ex) {
System.out.println(" 输入路径和文件路径不匹配,这是程序错误!");
}
}
}
/**
* 拷贝目标文件夹下面没有的文件
*/
public void copyLeftToTarget(FrameOur fo){
File temp = null;
for (int i = 0;this.allSourceFile != null && i <this.allSourceFile .length; i++) {
try {
temp = new File(this.outputPath +
this.getleft(this.allSourceFile[i].getAbsolutePath(),
this.inputPath));
if (!temp.exists()) {
System.out.println(" 复制目标文件夹下没有的文件: " + this.allSourceFile[i].getName() +" 至 " + this.outputPath);
temp.getParentFile().mkdirs();
fo.openFile(this.allSourceFile[i]);
// 将路段编号
bianma.initBianmaAtFree();
fo.saveFile(temp);
fo.reset();
}
}
catch (Exception ex) {
System.out.println(" 输入路径和文件路径不匹配,这是程序错误!");
}
}
}
/**
* 拷贝目标文件夹下面没有的文件
*/
public void copyCunDaoToTarget(FrameOur fo){
File temp = null;
for (int i = 0;this.allSourceFile != null && i <this.allSourceFile .length; i++) {
try {
temp = new File(this.outputPath +
this.getleft(this.allSourceFile[i].getAbsolutePath(),
this.inputPath));
if (!temp.exists()) {
System.out.println(" 复制目标文件夹下没有的村道文件: " + this.allSourceFile[i].getName() +" 至 " + this.outputPath);
temp.getParentFile().mkdirs();
fo.openFile(this.allSourceFile[i]);
// 将路段编号
// bianma.initBianmaAtFree();
fo.saveFile(temp);
fo.reset();
}
}
catch (Exception ex) {
System.out.println(" 输入路径和文件路径不匹配,这是程序错误!");
}
}
}
private String getleft(String rex, String replacement) throws Exception {
if (rex.indexOf(replacement) == -1) {
throw new Exception("字符不匹配!");
}
else {
return rex.substring(replacement.length(), rex.length());
}
}
public void scanAllCunDaoFile(String inputPath){
OpenDirectory od = new OpenDirectory();
od.setGradeStr("村道");
this.allSourceFile = od.getOpenFile(inputPath);
this.inputPath = inputPath;
}
public void scanAllZhuanyongFile(String inputPath){
OpenDirectory od = new OpenDirectory();
od.setGradeStr("专用道路");
this.allSourceFile = od.getOpenFile(inputPath);
this.inputPath = inputPath;
}
public static void main(String[] args) {
FileOper fileoper = new FileOper();
fileoper.setOutputPath("");
fileoper.scanAllCunDaoFile("E:\\temp\\枞阳县\\1\\");
for (int i = 0;fileoper.allSourceFile != null && i <fileoper.allSourceFile.length; i++) {
System.out.println("File["+i+"]:" + fileoper.allSourceFile[i].getAbsolutePath());
}
}
public void setOutputPath(String outputPath) {
this.outputPath = outputPath;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -