Skip to content

Instantly share code, notes, and snippets.

@masa25michi
Created October 25, 2015 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masa25michi/8f99ebe3ffdab190a301 to your computer and use it in GitHub Desktop.
Save masa25michi/8f99ebe3ffdab190a301 to your computer and use it in GitHub Desktop.
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();
}
}
}
}
@masa25michi
Copy link
Author

Usage of Basic PrintWriter in Java

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment