Android InputStream Save writeXmlToTempFile(InputStream xmlStream, String filePath, String closingTag)

Here you can find the source of writeXmlToTempFile(InputStream xmlStream, String filePath, String closingTag)

Description

write Xml To Temp File

Declaration

public static Boolean writeXmlToTempFile(InputStream xmlStream,
            String filePath, String closingTag) throws IOException 

Method Source Code

//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;
    }
}

Related

  1. saveFile(InputStream in, String fileName)
  2. saveToLocal(InputStream in, String filePath)
  3. writerFromInputStream(InputStream stream, String path, String fileName)
  4. writeFile(File outputFile, InputStream inputStream)
  5. saveFile(Context context, String fileName, InputStream inputStream)
  6. writeToString(InputStream stream)
  7. saveInputStreamAsFile(InputStream inputStream, File target)
  8. saveStream(InputStream is, String savePath)
  9. saveTmpFile(InputStream is)