文件拷贝,重现重复内容怎么办
我想通过一个程序复制一个java文件,也就是将 A.java 复制到 B.java 中去,
但是再复制的时候,出现了重复出现的情况,
也就是,程序好像讲缓冲区前面的部分重新写了一遍
大家说说应该怎么解决呢,嗯,上代码
只选取了文件的结尾部分
只选取了文件的结尾部分
但是再复制的时候,出现了重复出现的情况,
也就是,程序好像讲缓冲区前面的部分重新写了一遍
大家说说应该怎么解决呢,嗯,上代码
//复制的代码,感觉在缓冲区的时候有点问题
class FileCopy
{
FileInputStream FIS;
FileOutputStream FOS;
public boolean copyFile(File src, File des) {
try {
FIS = new FileInputStream(src);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
FOS = new FileOutputStream(des);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
byte[] bt = new byte[1024];
int readNum = 0;
try {
while( (readNum = FIS.read(bt)) != -1 ) {
FOS.write(bt, 0,bt.length);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
FIS.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
FOS.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return true;
}
}
只选取了文件的结尾部分
public class register_inquiry extends Domain
{
public register_inquiry()
{
TermVariable.initialize(2);
constants = new String[3];
constants[0] = "in";
constants[1] = "information";
constants[2] = "tool";
compoundTasks = new String[1];
compoundTasks[0] = "register_inquiry";
primitiveTasks = new String[1];
primitiveTasks[0] = "!register";
methods = new Method[1][];
methods[0] = new Method[1];
methods[0][0] = new Method0();
ops = new Operator[1][];
ops[0] = new Operator[1];
ops[0][0] = new Operator0();
axioms = new Axiom[3][];
axioms[0] = new Axiom[0];
axioms[1] = new Axiom[0];
axioms[2] = new Axiom[0];
}
}
只选取了文件的结尾部分
public class register_inquiry extends Domain
{
public register_inquiry()
{
TermVariable.initialize(2);
constants = new String[3];
constants[0] = "in";
constants[1] = "information";
constants[2] = "tool";
compoundTasks = new String[1];
compoundTasks[0] = "register_inquiry";
primitiveTasks = new String[1];
primitiveTasks[0] = "!register";
methods = new Method[1][];
methods[0] = new Method[1];
methods[0][0] = new Method0();
ops = new Operator[1][];
ops[0] = new Operator[1];
ops[0][0] = new Operator0();
axioms = new Axiom[3][];
axioms[0] = new Axiom[0];
axioms[1] = new Axiom[0];
axioms[2] = new Axiom[0];
}
}
//重复出现的部分
switch (which)
{
case 0:
p = (new Precondition0(unifier)).setComparator(null);
break;
default:
return null;
}
p.reset();
return p;
}
public String getLabel(int which)
{
switch (which)
{
case 0: return "Method0Branch0";
default: return null;
}
}
}
public class reg
//重复出现的情况结束
...全文
相关推荐
UG 经典问答50例
UG 经典问答50例 包含了UG的一些基本操作和常见问题,对初学者有一定的帮助...
不同工作簿之间工作表内容的拷贝
不同工作簿之间工作表内容的拷贝.rar 不同工作簿之间工作表内容的拷贝.rar
C++之深拷贝和浅拷贝
通过简短的代码和图片来说明C++中深拷贝和浅拷贝的区别和概念。
批处理拷贝文件(简单实用)
批处理拷贝文件(简单实用) 详细说明: D:\test为源路径 D:\test2为目标路径,可快速进行拷贝 系统 默认五个?
cmd 远程文件分发拷贝命令
通过远程连接把文件分发到客户端!把txt扩展名改成.bat 里边转换自己需要远程的计算机账号 密码 IP 等


Java SE
