Files and directories in java-lab 2

This post helps you to understand various files methods available.

File currentDirectory = new File(“E:\hai123.txt”);



Create a temporary file with name and extension. setOut methods helps you to write some contents into the file.

File temp = File.createTempFile("temp_", ".tmp", new File("E:/zip files"));
 System.setOut(new PrintStream(temp));
 System.out.println("hai how r u!!!!");

Hope this helps. Please subscribe and comment about this post.

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.