Here you can find the source of saveToFile(String prefix, Reader input)
public static File saveToFile(String prefix, Reader input)
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.Reader; public class Main { /************************************************************************/ public static File saveToFile(String prefix, Reader input) { File file;/* w ww .j av a 2s. c o m*/ BufferedWriter bw = null; try { file = File.createTempFile(prefix, null); bw = new BufferedWriter(new FileWriter(file)); BufferedReader inputReader = new BufferedReader(input); String thisLine; while ((thisLine = inputReader.readLine()) != null) { bw.write(thisLine); bw.newLine(); } inputReader.close(); } catch (IOException e) { throw new RuntimeException("Unable to store order: " + e.getMessage(), e); } finally { try { if (bw != null) { bw.close(); } } catch (IOException e) { } } return file; } }