Answer to Question #268807 in Java | JSP | JSF for Honour

Question #268807

develop a java console application that either overhaul or automate it.

Implement the following java concept in your solution and highlight in your documentation or code where you did it:

1. Class and Object

2. File and Stream

3. Exception Handling


1
Expert's answer
2021-11-19T14:39:20-0500


package filestream;


import java.io.File;
import java.io.IOException;




public class FileStream { //Class FileStream
  public void create_file(String name){
       try {
      File myObj = new File(name+".txt"); //File and stream
      if (myObj.createNewFile()) {
        System.out.println("File created: " + myObj.getName());
      } else {
        System.out.println("File already exists.");
      }
    } catch (IOException e) { //Exception Handling
      System.out.println("An error occurred.");
    }
  }
    public static void main(String[] args) {
       FileStream file  = new FileStream();
       // file is an instance of class FileStream
       file.create_file("filename");
    }
    
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS