Skip to main content

Posts

Showing posts with the label function of File class

Describe the function of File class? Create a DataInputStream for a file name "purbanchal.dat" and store "I am student of BIT VI semester" in that file.

 The File class in Java provides methods for working with files and directories. It allows you to create, delete, rename, and move files and directories, as well as retrieve information about them such as their size, creation time, and last modified time. It also provides methods for testing whether a file or directory exists, and whether it is readable, writable, or executable. To create a DataInputStream for a file named "purbanchal.dat" and store the string "I am a student of BIT VI semester" in that file, you can use the following code: import java.io.*; public class DataInputStreamExample {     public static void main(String[] args) {         String filename = "purbanchal.dat";         String message = "I am a student of BIT VI semester";         try {             // create a new file             File file = new File(filename);       ...