package de.nplusc.izc.tools.IOtools;


import java.io.*;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author LH
 */
public class StreamStore extends Thread
{
    InputStream is;
    String type;
    String tPath;
    
    /**
     * Ersteltden Streamdumper
     * @param is Stream zum DUmpen
     * @param type ungenutzt. altlasz
     * @param Path Wohin damit
     */
    public StreamStore(InputStream is, String type,String Path)
    {
        this.is = is;
        this.type = type;
        tPath=Path;
    }
    
    /**
     * startet den DUmp des Streams
     */
    @Override
    public void run()
    {   
        Thread t = new Thread(new Runnable() 
        {

        //@SuppressWarnings("SleepWhileInLoop")//Hx
        @SuppressWarnings("CallToThreadDumpStack")
        public void run()
            {
                try
                {
                    InputStreamReader isr = new InputStreamReader(is);
                    BufferedReader br = new BufferedReader(isr);
                    String line = null;
                    boolean r = true;
                    FileWriter f = new FileWriter(tPath);
                    BufferedWriter w = new BufferedWriter(f);
                    while ((line = br.readLine()) != null)//||true)//FAIL||r==true)
                    {
                        PrintStream p;
                        w.write(line);
                    }
                }
                catch (IOException ioe)
                {
                    ioe.printStackTrace();
                }
            }
        });
        
        t.start();
    }
}