Almost all the java.io package classes are streams. A stream is a carrier of data. To carry data, even sockets, use I/O streams. Infact, the methods getInputStream() and getOutputStream() of java.net.Socket returns an object of InputStream class and OutputStream class.
InputStreamReader and OutputStreamWriter are non-stream classes. They are not streams; they are converters or wrappers between input streams and output streams.
One more non-stream class in java.io package is File. Using this class, the properties of a file can be obtained like the file has got write permission or when the file is created etc.
Two programs are given using File class.
- File class – Retrieving Metadata of FileRetrieving File Metada
- File class – Changing File Properties
Retrieving File Metadata
The following program retrieves file metadata using different methods of File class.
import java.io.*;
public class FileMetaData
{
public static void main(String args[ ] ) throws IOException
{
System.out.println("pathSeparatorChar = " + File.pathSeparatorChar);
System.out.println("separatorChar = " + File.separatorChar);
File file1 = new File("pqr.txt");
System.out.println("getName(): " + file1.getName());
System.out.println("getAbsolutePath(): " + file1.getAbsolutePath()) ;
System.out.println("canRead(): " + file1.canRead()) ;
System.out.println("canWrite(): " + file1.canWrite()) ;
System.out.println("isFile(): " + file1.isFile()) ;
System.out.println("isDirectory: " + file1.isDirectory()) ;
System.out.println("File last modified date: " + file1.lastModified());
System.out.println("File size: " + file1.length() + " Bytes");
System.out.println("File exists(): " + file1.exists());
}
}

Output screenshot of File class Retrieve Metadata of File
explain The CLASSPATH Environment Variable
Whenever you load any software (like JDK, Tomcat etc.), you get two types files – executable files placed in bin folder and library files placed in lib folder. To recognize your software by the OS, set the address of bin folder in path and lib folder in classpath. path and classpath are known as environment variables.
What is environment variable?
It is a variable given by the OS to communicate with the running OS.