0

我想将输入流写入java中的文件。如何将内容写入java中的文本文件?

         try {

                BufferedReader in = new BufferedReader(new
                InputStreamReader(client.getInputStream()));

            //I want to write the content to a file line by line here
                 while (!in.ready()) {}

                 System.out.print("'\n");
                 in.close();
            }
4

1 回答 1

5
       FileWriter fstream = new FileWriter("fileName");
        BufferedWriter fbw = new BufferedWriter(fstream);

        while ((line = in.readLine()) != null) {

            fbw.write(line + "\n");

        }
于 2013-02-02T15:24:01.610 回答