Created
May 3, 2011 13:04
-
-
Save chriskoch/953290 to your computer and use it in GitHub Desktop.
schreibe in datei java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.FileNotFoundException; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import java.io.OutputStreamWriter; | |
import java.io.Writer; | |
public class Uebung31 { | |
public static void main(String[] args) { | |
String text = "Hallo Welt!"; | |
schreibeInDatei(text, "c:\\temp\\profil.html"); | |
} | |
/** | |
* https://gist.github.com/953290 | |
* | |
* @param inhalt | |
* @param fileName | |
*/ | |
public static void schreibeInDatei(String inhalt, String fileName) { | |
Writer datei = null; | |
try { | |
datei = new OutputStreamWriter(new FileOutputStream(fileName)); | |
} catch (FileNotFoundException fnf) { | |
fnf.printStackTrace(); | |
} | |
try { | |
datei.write(inhalt); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} finally { | |
try { | |
datei.close(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment