Flat Preloader Icon

Matcher pattern() method in Java with Examples

The pattern() method of Matcher Class is used to get the pattern to be matched by this matcher. Syntax: public Pattern pattern() Parameters: This method do not accepts any parameter. Return Value: This method returns a Pattern which is the pattern to be matched by this Matcher. Below examples illustrate the Matcher.pattern() method: import java.util.regex.*; … Read more

How to write Regular Expressions?

A regular expression (regex) is a sequence of characters that define a search pattern. Here’s how to write regular expressions: Start by understanding the special characters used in regex, such as “.”, “*”, “+”, “?”, and more. Choose a programming language or tool that supports regex, such as Python, Perl, or grep. Write your pattern … Read more

Regular Expressions in Java

In Java, Regular Expressions or Regex (in short) in Java is an API for defining String patterns that can be used for searching, manipulating, and editing a string in Java. Email validation and passwords are a few areas of strings where Regex is widely used to define the constraints. Regular Expressions in Java are provided … Read more

Java.io.RandomAccessFile Class Method 

Java.io.RandomAccessFile Class provides a way to random access files using reading and writing operations. It works like an array of byte storted in the File. Declaration : public class RandomAccessFile extends Object implements DataOutput, DataInput, Closeable Methods of RandomAccessFile Class read() : java.io.RandomAccessFile.read() reads byte of data from file. The byte is returned as an … Read more

Java.io.FileDescriptor in Java

java.io.FileDescriptor works for opening a file having a specific name. If there is any content present in that file it will first erase all that content and put “Beginning of Process” as the first line. Instances of the file descriptor class serve as an opaque handle to the underlying machine-specific structure representing an open file, … Read more

FileWriter Class in Java

Java FileWriter class of java.io package is used to write data in character form to file. Java FileWriter class is used to write character-oriented data to a file. It is a character-oriented class that is used for file handling in java. This class inherits from OutputStreamWriter class which in turn inherits from the Writer class … Read more

File Permissions in Java

Java provides a number of method calls to check and change the permission of a file, such as a read-only file can be changed to have permissions to write. File permissions are required to be changed when the user wants to restrict the operations permissible on a file. Checking the Current File Permissions A file … Read more

Delete a File Using Java

Java provides methods to delete files using java programs. On contrary to normal delete operations in any operating system, files being deleted using the java program are deleted permanently without being moved to the trash/recycle bin. Methods used to delete a file in Java: 1.Using java.io.File.delete() function: Deletes the file or directory denoted by this … Read more

Java Program to Write into a File

In this article, we will see different ways of writing into a File using Java Programming language. Java FileWriter class in java is used to write character-oriented data to a file as this class is character-oriented class because of what it is used in file handling in java. There are many ways to write into … Read more

Different ways of Reading a text file in Java

There are multiple ways of writing and reading a text file in Java. this is required while dealing with many applications. There are several ways to read a plain text file in Java e.g. you can use FileReader, BufferedReader, or Scanner to read a text file. Every utility provides something special e.g. BufferedReader provides buffering … Read more