Category: Java Tutorial

Java FileInputStream

Java FileInputStream

πŸ“‚ Java FileInputStream FileInputStream is a byte stream class used to read raw byte data from a file.It is mainly used for binary files like images, videos, or any non-text files, but can also...

Java I/O Streams

Java I/O Streams

πŸ’» Java I/O Streams In Java, I/O (Input/Output) Streams are used to read data from a source or write data to a destination. InputStream β†’ Read data (input) OutputStream β†’ Write data (output) Streams...

Java Delete Files

Java Delete Files

❌ Java Delete Files Java allows deleting files using: File.delete() (Old, simple method) Files.delete() or Files.deleteIfExists() (Modern, Java NIO) 1. Delete a File Using File.delete()

  Returns true if deletion is successful, false...

Java Read Files

Java Read Files

πŸ“– Java Read Files Java provides several ways to read data from files, mainly using: File + Scanner FileReader BufferedReader Files.readAllLines() (Java NIO) FileInputStream (for binary data) Β 1. Reading a File Using Scanner

...

Java Write to Files

Java Write to Files

πŸ“ Java Write to Files Java provides several ways to write data to files using: FileWriter BufferedWriter PrintWriter Files.write() (modern method) FileOutputStream (for binary data) Β 1. Using FileWriter (Simple Text Writing)

  🧩...

Java Create Files

Java Create Files

πŸ“ Java Create Files Java provides multiple ways to create a file using: java.io.File java.nio.file.Files (new and preferred method from Java 7+) βœ… 1. Creating a File Using File Class The createNewFile() method creates...

Java Files

Java Files

πŸ“ Java Files Java provides several classes to work with files, mainly from these packages: java.io.File java.io.FileWriter java.util.Scanner java.nio.file.Files (modern approach) You can perform tasks like: βœ” Create a fileβœ” Write to a fileβœ”...

Java Try-With-Resources

Java Try-With-Resources

πŸ”§ Java Try-With-Resources (Automatic Resource Management) When working with resources such as: Files Database connections Network streams Buffered readers/writers You must close them after use β€” otherwise memory leaks or file locks may occur....

Java Multiple Exceptions

Java Multiple Exceptions

⚠️ Java Multiple Exceptions In Java, a single try block can throw more than one type of exception. To handle this, we can use: Multiple catch blocks Single catch block using multi-catch (Java 7+)...

Java Exceptions

Java Exceptions

⚠️ Java Exceptions – try…catch An exception is an event that disrupts the normal flow of a program. Exceptions usually occur during runtime β€” like dividing by zero, accessing invalid array indices, or opening...