Maruthi Krishna has Published 952 Articles

How to filter the files by file extensions and show the file names in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 02-Aug-2019 11:06:45

2K+ Views

The class named File of the java.io package represents a file or directory (path names) in the system. This class provides various methods to perform various operations on files/directories.To get the list of all the existing files in a directory this class provides five different methods to get the details of ... Read More

How many ways can we read data from the keyboard in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 01-Aug-2019 14:27:57

3K+ Views

The java.io package provides various classes to read write data from various sources and destinations.You can read data from user (keyboard) using various classes such as, Scanner, BufferedReader, InputStreamReader, Console etc.Using Scanner classFrom Java 1.5 Scanner class was introduced. This class accepts a File, InputStream, Path and, String objects, reads ... Read More

How to set file permissions in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 01-Aug-2019 14:22:20

6K+ Views

In general, whenever you create a file you can restrict/permit certain users from reading/writing/executing a file.In Java files (their abstract paths) are represented by the Files class of the java.io package. This class provides various methods to perform various operations on files such as read, write, delete, rename etc.In addition, ... Read More

Is it possible to change directory by using File object in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 01-Aug-2019 14:18:13

1K+ Views

The File classThe class named File of the java.io package represents a file or directory (path names) in the system. This class provides various methods to perform various operations on files/directories.This class provides various methods to manipulate files, The renameTo() method of the File class accepts a String representing a destination ... Read More

How to read contents of a file using Scanner class?

Maruthi Krishna

Maruthi Krishna

Updated on 01-Aug-2019 14:08:57

12K+ Views

From Java 1.5 Scanner class was introduced. This class accepts a File, InputStream, Path and, String objects, reads all the primitive data types and Strings (from the given source) token by token using regular expressions. By default, whitespace is considered as the delimiter (to break the data into tokens).To read ... Read More

What is Scanner class in Java? when was it introduced?

Maruthi Krishna

Maruthi Krishna

Updated on 01-Aug-2019 14:03:58

321 Views

Until Java 1.5 to read data from the user programmers used to depend on the character stream classes and byte stream classes.From Java 1.5 Scanner class was introduced. This class accepts a File, InputStream, Path and, String objects, reads all the primitive data types and Strings (from the given source) ... Read More

What is the necessity of byte streams and character streams in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 01-Aug-2019 14:00:08

458 Views

Java provides I/O Streams to read and write data where, a Stream represents an input source or an output destination which could be a file, i/o devise, other program etc.Based on the data they handle there are two types of streams −Byte StreamsThese handle data in bytes (8 bits) i.e., ... Read More

How to create a new directory by using File object in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 01-Aug-2019 13:54:30

5K+ Views

The class named File of the java.io package represents a file or directory (path names) in the system. This class provides various methods to perform various operations on files/directories.Creating a new directoryThe mkdir() method of this class creates a directory with the path represented by the current object.Therefore, to create ... Read More

How to read data from a file using FileInputStream?

Maruthi Krishna

Maruthi Krishna

Updated on 01-Aug-2019 13:48:45

3K+ Views

The FileInputStream class reads the data from a specific file (byte by byte). It is usually used to read the contents of a file with raw bytes, such as images.To read the contents of a file using this class −First of all, you need to instantiate this class by passing ... Read More

What is the use of FileInputStream and FileOutputStream in classes in Java?

Maruthi Krishna

Maruthi Krishna

Updated on 01-Aug-2019 13:42:15

12K+ Views

Java provides I/O Streams to read and write data where, a Stream represents an input source or an output destination which could be a file, i/o devise, other program etc.There are two types of streams available −InputStream − This is used to read (sequential) data from a source.OutputStream − This ... Read More

Advertisements