Created
January 24, 2009 06:17
-
-
Save gcr/51363 to your computer and use it in GitHub Desktop.
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.*; | |
/* | |
** Demonstrates how to set up a pathway between program and disk file | |
*/ | |
public class FileOutputDemo { | |
public static void main(String[] args) throws IOException { | |
// use File | |
File f1 = new File ("first.dta"); | |
FileOutputStream fileStream = new FileOutputStream (f1); | |
PrintWriter target = new PrintWriter (fileStream); | |
target.println ("I really like Java Programming."); | |
target.println ("It is a powerful OO programming language."); | |
target.flush(); | |
// use filename | |
String filename = "second.dta"; | |
fileStream = new FileOutputStream (filename); | |
target = new PrintWriter (fileStream); | |
target.println ("This is the second file.”); | |
target.flush(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment