Linux 文件的复制,移动(剪切、改名)和删除(强制删除)

复制:

当前路径:cp    xxx     /yyy

绝对路径:cp   /xxx    /yyy

复制目录: cp  -r   /xxx/aaa    /yyy

复制目录保持属性: cp  -rp   /xxx/aaa    /yyy

移动(剪切、改名):

当前路径:mv   xxx     /yyy

绝对路径:mv   /xxx    /yyy

改名:

当前路径: mv   xxx   yyy

删除(强制删除):

删除: rm   -r   xxx (会有确认提示)

强制删除: rm -rf xxx  (适合多文件删除)

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
好的,我可以为您提供一个简单的Java代码,用于实现文件管理系统。该系统可以执行剪切复制删除文件的功能。以下是代码: ```java import java.io.*; public class FileManager { // 剪切文件 public static void cutFile(String sourceFilePath, String destinationFilePath) throws IOException { File sourceFile = new File(sourceFilePath); File destinationFile = new File(destinationFilePath); if (sourceFile.exists()) { InputStream in = new FileInputStream(sourceFile); OutputStream out = new FileOutputStream(destinationFile); byte[] buffer = new byte[1024]; int length; while ((length = in.read(buffer)) > 0) { out.write(buffer, 0, length); } in.close(); out.close(); sourceFile.delete(); System.out.println("文件剪切成功!"); } else { System.out.println("文件不存在!"); } } // 复制文件 public static void copyFile(String sourceFilePath, String destinationFilePath) throws IOException { File sourceFile = new File(sourceFilePath); File destinationFile = new File(destinationFilePath); if (sourceFile.exists()) { InputStream in = new FileInputStream(sourceFile); OutputStream out = new FileOutputStream(destinationFile); byte[] buffer = new byte[1024]; int length; while ((length = in.read(buffer)) > 0) { out.write(buffer, 0, length); } in.close(); out.close(); System.out.println("文件复制成功!"); } else { System.out.println("文件不存在!"); } } // 删除文件 public static void deleteFile(String filePath) { File file = new File(filePath); if (file.exists()) { file.delete(); System.out.println("文件删除成功!"); } else { System.out.println("文件不存在!"); } } } ``` 上述代码使用Java的IO流操作,实现了剪切复制删除文件的功能。您只需要调用相应的方法并传入文件路径,即可完成对应的文件操作。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

80后大叔爱学习

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值