Here you can find the source of writeXmlToTempFile(InputStream xmlStream, String filePath, String closingTag)
public static Boolean writeXmlToTempFile(InputStream xmlStream, String filePath, String closingTag) throws IOException
//package com.java2s; import java.io.*; public class Main { public static Boolean writeXmlToTempFile(InputStream xmlStream, String filePath, String closingTag) throws IOException { Boolean downloadSuccessful = false; File tempFile = new File(filePath); FileOutputStream stream = new FileOutputStream(tempFile); BufferedReader reader = new BufferedReader(new InputStreamReader( xmlStream));/* w w w .j a v a2s .c o m*/ String line; while ((line = reader.readLine()) != null) { stream.write(line.getBytes()); // Check if we downloaded successfully if (downloadSuccessful == false && line.toLowerCase() .contains(closingTag.toLowerCase())) { downloadSuccessful = true; } } stream.close(); reader.close(); return downloadSuccessful; } }