Home » Core Java » io (page 3)

io

Java read file Example

In this example we will show how to open and read a file in Java. There are many ways to do this, but we will show two of them. For this example, we will read the contents of a text file named “test_file.txt”. 1. Read a file using BufferedReader This is the most commonly-used method in order to read a ...

Read More »

Java FilenameFilter Example

In this example we are going to talk about Java FilenameFilter interface. FilenameFilter is a very convenient interface that helps you filter out specific file names when listing a folder. So, as you might imagine, it is particularly useful for applications that have to navigate through big file systems. Filter file extension In order to use the FilenameFilter class to ...

Read More »

Java InputStreamReader Example

In this example we are going to talk about InputStreamReader Java Class. InputStreamReader is a subclass of Reader. A Reader‘s job is to connect your program to a data source, and fetch data from that source and make them available to your program for manipulation. But its purpose is to bridge the byte stream from that source to a character ...

Read More »

Java BufferedReader Example

In this example we are going to talk about BufferedReader Java class. BufferedReader is a subclass of Reader class. As you might know, Reader is a utility class for reading character streams. Such a stream could be obtained from a text file, from the console , from a socket, from a pipe , from a database or even from a ...

Read More »

Java FileReader Example

In this example we are going to see how to use FileReader Java class in order to read characters from a file. As you might remember from a previous FileInpustream Example it is easy to wrap an InputStream, that creates an input byte stream, to a Reader class that bridges a byte stream to a character stream. To be more ...

Read More »

java.io.FileOutputStream Example

In this example we are going to talk about FileOutputStream. FileOutputStream is a subclass of OutputStream, which is used to transfer data from your program to a resource. And in this case to a file that resides in your underlying file system. OK, so let’s start with some simple examples.             1. Writing bytes to ...

Read More »

java.io.OutputStream Example

In this example we are going to talk about OutputStream class in Java. OutputStream is an abstract class that enables you to write data to an output sink or destination. As with InputStream, that destination could be a console, a file, a socket, a pipe and even a buffer in memory. The most basic and fundamental thing you can do ...

Read More »

java.io.FileInputStream Example

In this example we are going to see how to use FileInputStream in Java. FileInputStream in an InputStream subclass that is used to read data from files in a file system. It is actually connected to a specific files, and can be used to extract data from them and make them available inside your program for manipulation. As with InputStream, ...

Read More »

java.io.InputStream Example

In this example we are going to talk about a very important Java class, InputStream. If you have even the slightest experience with programming in Java, chances are that you’ve already used InputStream in one of your programs, or one of its subclasses, like FileInputStream or BufferedInputStream. You see, InputStream is an abstract class, that provides all the necessary API ...

Read More »

Java write to File Example

In this post, we feature a comprehensive Java write to File Example. We are going to investigate several methods to write a File in Java. We will list some of the older, before Java 7 and NIO, methods to write to a text or a binary file as well as some of the modern ones. You are also going to ...

Read More »