※ 引述《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
[