Java #28: How to Create and Write to a File in Java

———–Full Source Code—————
//Programmer:Akinwale Owi
//Company: Dagba Computers
//Program Purpose:Create and Write a File in Java

package dagbacomputers;


//Beginning of DagbaComputers (Class containing the Main function)
public class DagbaComputers {

public static void main(String[] args)
//beginning of the try
//Creating and Writing the new File
PrintWriter lineWriter = new PrintWriter(“BrandNew.txt”, “UTF-8”);

//Writing to the File
lineWriter.printf(“Welcome to your new file!” + “\n”);

//Closing the File
}catch (IOException e){}//exception – in case there is an error

//End of try
//End of Main Function
//End of DagbaComputers Class

————-Output(After running, I found and opened the file, should be able to just go to your documents and type the file name)———–

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s