- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 4338 Articles for Java 8
![Maruthi Krishna](https://www.tutorialspoint.com/assets/profiles/119958/profile/60_3780337-1641548568.png)
3K+ 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 all files in a particular folder −String[] list()File[] listFiles()String[] list(FilenameFilter filter)File[] listFiles(FilenameFilter filter)File[] listFiles(FileFilter filter)Among these, the String[] list(FilenameFilter filter) method returns a String array containing the names of all the files and directories in the path represented by the current (File) object. But the retuned array contains the filenames ... Read More
![Maruthi Krishna](https://www.tutorialspoint.com/assets/profiles/119958/profile/60_3780337-1641548568.png)
36K+ 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 the files class provides list() (returns names) and ListFiles() (returns File objects) with different variants.The List() methodThis method returns a String array which contains the names of all the files and directories in the path represented by the current (File) object.Using this method, you can just print the names of the files and directories.ExampleThe following Java program ... Read More
![Maruthi Krishna](https://www.tutorialspoint.com/assets/profiles/119958/profile/60_3780337-1641548568.png)
908 Views
Enumeration (enum) in Java is a datatype which stores a set of constant values. You can use enumerations to store fixed values such as days in a week, months in a year etc.enum Days { SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY }You can also define an enumeration with custom values to the constants declared. But you need to have an instance variable, a constructor and getter method to return values.Using enumeration with switchA switch statement allows a variable to be tested for equality against a list of values. Each value is called a case, and the variable being ... Read More
![Maruthi Krishna](https://www.tutorialspoint.com/assets/profiles/119958/profile/60_3780337-1641548568.png)
442 Views
In general, arrays are the containers that store multiple variables of the same datatype. These are of fixed size and the size is determined at the time of creation. Each element in an array is positioned by a number starting from 0.You can access the elements of an array using name and position as −System.out.println(myArray[3]); //Which is 1457Creating an array in JavaIn Java, arrays are treated as referenced types you can create an array using the new keyword similar to objects and populate it using the indices as −int myArray[] = new int[7]; myArray[0] = 1254; myArray[1] = 1458; myArray[2] ... Read More
![Maruthi Krishna](https://www.tutorialspoint.com/assets/profiles/119958/profile/60_3780337-1641548568.png)
2K+ Views
In Java classes and interfaces related to each other are grouped under a package. Package is nothing but a directory storing classes and interfaces of a particular concept. For example, all the classes and interfaces related to input and output operations are stored in java.io package.Creating a packageYou can group required classes and interfaces under one package just by declaring the package at the top of the Class/Interface (file) using the keyword package as −package com.tutorialspoint.mypackage; public class Sample{ public void demo(){ System.out.println("This is a method of the sample class"); } public static void main(String ... Read More
![Maruthi Krishna](https://www.tutorialspoint.com/assets/profiles/119958/profile/60_3780337-1641548568.png)
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 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 data from keyboard you need to use standard input as source (System.in). For each datatype a nextXXX() is ... Read More
![Maruthi Krishna](https://www.tutorialspoint.com/assets/profiles/119958/profile/60_3780337-1641548568.png)
7K+ 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, this class also provides the following methods −setExecutble() − This method is sued to set the execute permissions to the file represented by the current (File) object.setWritable() − This method is used to set the write permissions to the file represented by the current (File) object.setReadable() − This method is ... Read More
![Maruthi Krishna](https://www.tutorialspoint.com/assets/profiles/119958/profile/60_3780337-1641548568.png)
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 file and, renames the abstract file path of the current file to the given one.This method actually moves the file from source path to the destination path.Exampleimport java.io.File; public class MovingFile { public static void main(String args[]) { //Creating a source file object ... Read More
![Maruthi Krishna](https://www.tutorialspoint.com/assets/profiles/119958/profile/60_3780337-1641548568.png)
2K+ 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).Reading a character using the Scanner classScanner class provides nextXXX() (where xxx is int, float, boolean etc) methods which are used to read various primitive datatypes. But it never provides a method to read a single character.But, you still can read a single character using this class.The next() method of the Scanner ... Read More
![Maruthi Krishna](https://www.tutorialspoint.com/assets/profiles/119958/profile/60_3780337-1641548568.png)
13K+ 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 various datatypes from the source using the nextXXX() methods provided by this class.Reading the contents of a file −To read the contents of a file, Scanner class provides various constructors.Sr.NoConstructors and Description1Scanner(File source)Used to read data from the file represented by the given File object.2Scanner(InputStream source)Used to read data from ... Read More