java的文件输入另一个文件_文件I / O:从一个文件读取并写入另一个文件(Java)

我目前正在我的cpe类中的一个实验室工作,我们必须创建一个简单的程序,它从.txt文件中扫描字符串并将它们打印到不同的.txt文件.到目前为止,我已经绘制了基本程序,但是我的异常一直在扔,尽管我有所有必要的文件.任何人都可以帮我调试吗?

import java.io.*;

import java.util.*;

public class FileIO {

public static void main(String args[]) {

try {

File input = new File("input");

File output = new File("output");

Scanner sc = new Scanner(input);

PrintWriter printer = new PrintWriter(output);

while(sc.hasNextLine()) {

String s = sc.nextLine();

printer.write(s);

}

}

catch(FileNotFoundException e) {

System.err.println("File not found. Please scan in new file.");

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值