File 类有方法,可以移动。
解决方案 »
- JNDI是什么?
- 如何学习好JAVA
- 哪位高手能帮我指导一下,红色部分根本未执行,谢谢!
- Properties 取属性文件的问题,可能是编码的问题,请指点一下
- 关于在线程中使用socket的问题
- 求助!谁知道使用XSLTInputSource的插件是什么?
- JComboBox的工具条提示
- JDBC的问题?
- 那位大侠知道java编程指南(1.4)的电子书籍下载地址啊??????
- JMenu 快捷键无效
- 在线求助 System.out.println(spa1--<=0&&day1<cou1?day1<10?" 0"+day1++:" "+day1++:" ");怎么运行的?
- ■□■□■ 不使用jb,用jdk怎么能把程序编译成exe?????
public class FileMove
{
public static void main(String[] args)
{
File fsource=new File("c:\\q.txt");
File fdest=new File("d:\\a.txt");
fsource.renameTo(fdest);
//把c:\q.txt移动到d:\下,且改名为a.txt
}
}
用renameTo好像能否成功好像还取决于系统平台
Whether or not this method can move a file from one filesystem to another is platform-dependent