问题
I want to write the inputstream into a file in java. How to write the contents into a text file in 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();
}
回答1:
FileWriter fstream = new FileWriter("fileName");
BufferedWriter fbw = new BufferedWriter(fstream);
while ((line = in.readLine()) != null) {
fbw.write(line + "\n");
}
来源:https://stackoverflow.com/questions/14663346/writing-the-contents-to-a-file-from-input-stream