- 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
352 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) 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 namely, nextInt(), nextShort(), nextFloat(), nextLong(), nextBigDecimal(), nextBigInteger(), nextLong(), nextShort(), nextDouble(), nextByte(), nextFloat(), next().Example − Reading data from ... Read More
514 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., the byte stream classes read/write data of 8 bits. Using these you can store characters, videos, audios, images etc.The InputStream and OutputStream classes (abstract) are the super classes of all the input/output stream classes: classes that are used to read/write a stream of bytes. Following are the byte array stream ... Read More
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 a directory −Instantiate the File class by passing the path of the directory you need to create, as a parameter (String).Invoke the mkdir() method using the above created file object.ExampleFollowing Java example reads the path and name of the directory to be created, from the user, and creates it.import java.io.File; ... Read More
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 a String variable or a File object, representing the path of the file to be read.FileInputStream inputStream = new FileInputStream("file_path"); or, File file = new File("file_path"); FileInputStream inputStream = new FileInputStream(file);Then read the contents of the specified file using either of the variants of read() method −int read() − This ... Read More
13K+ 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 is used to write data to a destination.FileInputStreamThis 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 ... Read More
10K+ 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 is used to write data to a destination.FileInputStreamThis 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.Converting an InputStream object to StringYou can convert an InputStream Object int to a String ... Read More
3K+ 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 Streams − These handle data in bytes (8 bits) i.e., the byte stream classes read/write data of 8 bits. Using these you can store characters, videos, audios, images etc.Character Streams − These handle data in 16 bit Unicode. Using these you can read and write text data only.The Reader and Writer classes (abstract) are the super classes of ... Read More
24K+ 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.In general, a Stream will be an input stream or, an output stream.InputStream − This is used to read data from a source.OutputStream − This is used to write data to a destination.Based on the data they handle there are two types of streams −Byte Streams − These handle data in bytes (8 bits) i.e., the byte stream classes read/write data of 8 bits. Using these you can store characters, videos, ... Read More
2K+ Views
The BufferedWriter class of Java is used to write stream of characters to the specified destination (character-output stream). It initially stores all the characters in a buffer and pushes the contents of the buffer to the destination, making the writing of characters, arrays and Strings efficient.You can specify the required size of the buffer at the time of instantiating this class.The flush() methodWhile you are trying to write data to a Stream using the BufferedWriter object, after invoking the write() method the data will be buffered initially, nothing will be printed.The flush() method is used to push the contents of ... Read More
128 Views
To compare two objects, the Object class provides a method with name equals(), this method accepts an object and compares it with the current object.If the references of these two objects are equal, then it returns true else this method returns false.But this method returns true only if both references points to the same object. In fact, it should return true id the contents of the both objects are equal.Exampleclass Employee { private String name; private int age; Employee(String name, int age){ this.name = name; this.age = age; } } ... Read More