File Handling with JAVA
I/O Streams
There are two types of Streams you can use to interact with files:
Character Streams
Byte Streams
For each of the above stream types, there are several supporting classes shipped with Java, which we'll take a quick look at below.
Character Streams
Character Streams are used to read or write the characters data type. Let's look at the most commonly used classes. All of these classes are defined under java.io package.
Here are some classes you should know that can be used to read character data:
Reader: An abstract class to read a character stream.
InputStreamReader: Class used to read the byte stream and converts to character stream.
FileReader: A class to read the characters from a file.
BufferedReader: This is a wrapper over the Reader class that supports buffering capabilities. In many cases this is most preferable class to read data because more data can been read from the file in one read() call, reducing the number of actual I/O operations with file system.
And here are some classes you can use to write character data to a file:
Writer: This is an abstract class to write the character streams.
OutputStreamWriter: This class is used to write character streams and also convert them to byte streams.
FileWriter: A class to actually write characters to the file.
BufferedWriter: This is a wrapper over the Writer class, which also supports buffering capabilities. This is most preferable class to write data to a file since more data can be written to the file in one write() call. And like the BufferedReader, this reduces the number of total I/O operations with file system.
Byte Streams
Byte Streams are used to read or write byte data with files. This is different from before in the way they treat the data. Here you work with raw bytes, which could be characters, image data, unicode data (which takes 2 bytes to represent a character), etc.
In this section we'll take a look at the most commonly used classes. All of these classes are defined under java.io package.
Here are the classes used to read the byte data:
InputStream: An abstract class to read the byte streams.
FileInputStream: A class to simply read bytes from a file.
BufferedInputStream: This is a wrapper over InputStream that supports buffering capabilities. As we saw in the character streams, this is a more efficient method than FileInputStream.
And here are the classes used to write the byte data:
OutputStream: An abstract class to write byte streams.
FileOutputStream: A class to write raw bytes to the file.
ByteOutputStream: This class is a wrapper over OutputStream to support buffering capabilities. And again, as we saw in the character streams, this is a more efficient method than FileOutputStream thanks to the buffering.
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «File Handling with JAVA», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.