/*自己整理一下吧*/
String source = "d:/websrc/aaa.txt";
String aim = "d:/websrc/aaa.bak";
FileInputStream in = new FileInputStream(source);
FileOutputStream out = new FileOutputStream(aim);
byte[] buffer = new byte[1024];
int length = -1;
while((length=in.read(buffer))!=-1){
out.write(buffer,0,length);
}
out.flush();
out.close();
in.close();
String source = "d:/websrc/aaa.txt";
String aim = "d:/websrc/aaa.bak";
FileInputStream in = new FileInputStream(source);
FileOutputStream out = new FileOutputStream(aim);
byte[] buffer = new byte[1024];
int length = -1;
while((length=in.read(buffer))!=-1){
out.write(buffer,0,length);
}
out.flush();
out.close();
in.close();
import java.io.*;class exectest
{
public static void main(String[] args)
{
try {
String cmd = "cmd /c copy web.html newweb.html";
//String cmd = "E:\\Program Files\\Internet Explorer\\IEXPLORE.EXE";
Process child = Runtime.getRuntime().exec(cmd);
} catch (IOException e) {
System.err.println(e);
}
}}
我只知道vb,vc中直接可以copy的,不知道java中有没有
while((c=ifs.read())!=-1){
ofs.write(c);
}
try {
File file=new File(str);
InputStream is=null;
OutputStream os=null;
byte[] b;
File f=new File(str1);
if(!file.isDirectory()) {
is=new FileInputStream(str);
b=new byte[is.available()];
is.read(b);
os=new FileOutputStream(str1);
os.write(b);
is.close();
os.close();
return;
} else if(!f.exists())
f.mkdirs();
File[] filename=file.listFiles();
for(int i=0;i<filename.length;i++) {
copyfile(filename[i].getAbsolutePath(),str1+"/"+filename[i].getName());
}
} catch(IOException ex) {
filecopycount++;
System.out.println("filecopycount:"+String.valueOf(filecopycount));
if(filecopycount<=5)
copyfile(str,str1);
System.err.println("err:"+ex.toString());
}
}