如给出:“E:/eclipse3.02/2024/200386-4917.jpg”
怎样将该文件拷贝到另外一个目录?
若子目录不存在自动创建。“F:/MYFILES/2024/200386-4917.jpg”
怎样将该文件拷贝到另外一个目录?
若子目录不存在自动创建。“F:/MYFILES/2024/200386-4917.jpg”
解决方案 »
- 使用hibernate3.2 注解 自动创建数据库, 我是说database 不是表结构 能自动创建吗
- 紧急求助,有分,在线等,过了今天就没分了哈
- 我用<a href="C:\Program Files\Real\RealOne Player\realplay.exe">realone</a>,打不开本地文件
- 如何在JTextArea中实现文本随时间的自动滚动(像迷你歌词一样)??
- 初学者请求帮忙————很菜的问题。
- 能生成可执行文件吗?
- 怎么用jb5创建一个corba工程?
- 急急急!!!注册码!!!快来抢分!!!!~!!
- 为什么String类和StringBuffer测试耗费内存相同呢?
- JAVA输出到TXT文件希望能换行输出
- 谁能讲解一下这个简单的题目,初学者
- 退出线程问题
");
File fcopy = new File("F:\\\MYFILES\\2024\\200386-4917.jpg");
fcopy.createNewFile() ;
FileOutputStream fout = new FileOutputStream(fcopy);
int b;
while((b=fin.read())!=-1){
fout.write(b);注意文件分隔符
File inf = new File(in);
if(!inf.exists())
return;
File outf = new File(out);
String outPath[] = out.split("/");
String tmp =outPath[0];
for(int i =1; i< outPath.length -1;i++)
{ tmp = tmp +"/" + outPath[i];
outf =new File(tmp +"/");
if(!outf.exists())
{
outf.mkdir();
}
}
outf =new File(out);
FileInputStream fis = null;
try {
fis = new FileInputStream(inf);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
FileOutputStream fos = null;
try {
fos = new FileOutputStream(outf);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
byte[] buf = new byte[1024];
int i = 0;
while((i=fis.read(buf))!=-1) {
fos.write(buf, 0, i);
}
fis.close();
fos.close();
}
//call :
try {
a.CopyFile("d:/aa/aa.bmp","d:/aa/bb/aa.bmp");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}