jcreator Note:uses or overrides a deprecated API与此无关

解决方案 »

  1.   

    out=new FileOutputStream("out.txt",true)
    试试
      

  2.   

    用FileWriter(file,true);
    file是你要写的文件
      

  3.   

    import java.io.*;public class FWriter {
        public FWriter(String path, String name, String content, boolean append, boolean autoLine) throws IOException
        {
            if(path.charAt(path.length()-1)!='/') {
                path = path + "/";
            }
            String file_path = path;
            String file_name = name;
            makeDir(file_path);
            File file = new File(file_path + File.separator + file_name);
            PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file,append)));
            if(autoLine)
                pw.println(content);
            else
                pw.write(content);
            pw.flush();
            pw.close();
        }    public FWriter() {
            System.out.println("[FWriter]: Shit! I need parameters!");
        }    private void makeDir(String url){
            String path = url.substring(0,url.lastIndexOf("/")+1);
            File file_path = new File(path);
            file_path.mkdirs();
        }    public static void main(String[] args) {
            try
            {
                FWriter fw = new FWriter("f:/temp/test/", "测试.txt", "", false, false);
                for(int i=1; i<=10; i++) {
                    FWriter fwr1 = new FWriter("f:/temp/test/", "测试.txt", "测试! (" + i + ")", true, true);
                }
                System.out.println("[FWriter]: done!");
            }
            catch(IOException ioe)
            {
                System.out.println(ioe.toString());
            }
        }
    }
      

  4.   

    Eraserpro(Eraser,毁灭者?橡皮?) 能否具体一些?
      

  5.   

    非常感谢alemjann(裸睡) ( ) 
    但是你的程序有些小问题
    “PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file,append)));”出错F:\java\program\jc\FWriter.java:13: Incompatible type for constructor. Can't convert java.io.File to java.lang.String.
            PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(file,append)));
    请问如何改,谢谢
      

  6.   

    传入的第5个参数改为true即可。