Start Klasse aufgeräumt
This commit is contained in:
parent
521f289564
commit
490f1d2cbb
@ -6,42 +6,14 @@
|
|||||||
|
|
||||||
package chatprogramm;
|
package chatprogramm;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
|
||||||
import java.io.BufferedOutputStream;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builder Class
|
* Builder Class
|
||||||
* @author le
|
* @author le
|
||||||
*/
|
*/
|
||||||
public class Start
|
public class Start
|
||||||
{
|
{
|
||||||
public Start(String urlString, String dateiname) throws MalformedURLException, IOException
|
public Start()
|
||||||
{
|
{
|
||||||
URL oUrl = new URL(urlString + "/" + dateiname);
|
|
||||||
InputStream iStream = oUrl.openStream();
|
|
||||||
BufferedInputStream in = new BufferedInputStream(iStream);
|
|
||||||
|
|
||||||
String tmpVerzeichnis = System.getProperty("java.io.tmpdir");
|
|
||||||
String ausgabeDateiname = tmpVerzeichnis + File.separator + dateiname;
|
|
||||||
|
|
||||||
FileOutputStream fos = new FileOutputStream(ausgabeDateiname);
|
|
||||||
BufferedOutputStream out = new BufferedOutputStream(fos);
|
|
||||||
|
|
||||||
int wert = 0;
|
|
||||||
|
|
||||||
while ( (wert = in.read()) >= 0)
|
|
||||||
{
|
|
||||||
out.write(wert);
|
|
||||||
}
|
|
||||||
in.close();
|
|
||||||
out.close(); // flush!
|
|
||||||
System.out.println("Datei " + ausgabeDateiname + " erfolgreich erstellt");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,21 +22,6 @@ public class Start
|
|||||||
*/
|
*/
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
if (args.length != 2)
|
new Start();
|
||||||
{
|
|
||||||
System.err.println("2 Aufrufparameter nötig: URL-String Dateiname");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
new Start(args[0], args[1]);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
System.err.println(ex);
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user