Created
October 25, 2015 08:19
-
-
Save masa25michi/8f99ebe3ffdab190a301 to your computer and use it in GitHub Desktop.
This file contains 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.PrintWriter; | |
import java.io.File; | |
import java.io.*; | |
public class t1{ | |
public static void main(String [] args) | |
{ | |
String fileName = "t1.txt"; | |
File file = new File (fileName); | |
PrintWriter printWriter = null; | |
try | |
{ | |
printWriter=new PrintWriter (file); | |
printWriter.println("hello"); | |
}catch (FileNotFoundException e) | |
{ | |
e.printStackTrace(); | |
}finally | |
{ | |
if(printWriter!=null) | |
{ | |
printWriter.close(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage of Basic PrintWriter in Java