Browse Source

Start Klasse aufgeräumt

master
Gerhard Switalski 6 years ago
parent
commit
490f1d2cbb
1 changed files with 2 additions and 45 deletions
  1. 2
    45
      src/chatprogramm/Start.java

+ 2
- 45
src/chatprogramm/Start.java View File



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");
} }


*/ */
public static void main(String[] args) public static void main(String[] args)
{ {
if (args.length != 2)
{
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();
}
}
new Start();
} }
} }

Loading…
Cancel
Save