※ 引述《akk98 (akk)》之铭言:
: import java.io.BufferedWriter;
: import java.io.IOException;
: public class FileWriter {
: public static void main(String[] args) {
: try {
: String fpath = "D:/abc/test.txt";
: BufferedWriter fout = new BufferedWriter(new FileWriter(fpath));
: fout.write("花花世界看看世界");
: fout.newLine();
: fout.close();
: System.out.println("写档完成");
: }catch (IOException e) {
: e.printStackTrace();
: }
: }
: }
: BufferedWriter fout = new BufferedWriter(new FileWriter(fpath))
: 这行出错误了 是版本问题吗? 还是少了什么???
先简单地,复制你的 code 来 compile
=================================================================
qty:Downloads qrtt1$ javac FileWriter.java
FileWriter.java:10: error: constructor FileWriter in class FileWriter
cannot be applied to given types;
BufferedWriter fout = new BufferedWriter(new FileWriter(fpath));
^
required: no arguments
found: String
reason: actual and formal argument lists differ in length
1 error
qty:Downloads qrtt1$
它说,你写的 FileWriter 的建构子,不能塞你指定的 type
[