Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the test questions that Java IO often meets?

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "what are the test questions you often meet with Java IO". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "what are the questions you meet frequently in Java IO?"

1. What is an IO stream?

It is a stream of data from source to destination. For example, file copy, input stream and output stream are all included. The input stream reads the data from the file and stores it in the process (process), and the output stream reads the data from the process and writes it to the target file.

two。 The difference between byte stream and character stream.

Byte streams are introduced in JDK1.0 to manipulate files that contain ASCII characters. JAVA also supports other characters such as Unicode. In order to read files containing Unicode characters, JAVA language designers introduced character streams into JDK1.1. As a subset of Unicode, ASCII can use either byte stream or character stream for files with English characters.

What are the main superclasses of stream classes in 3.Java?

Java.io.InputStream

Java.io.OutputStream

Java.io.Reader

Java.io.Writer

4. What are FileInputStream and FileOutputStream?

These are two classes that are often used when copying files. They perform well when dealing with small files, but it is best to use BufferedInputStream (or BufferedReader) and BufferedOutputStream (or BufferedWriter) when dealing with large files.

5. Do you prefer to use byte stream and character stream?

Personally, they prefer to use character streams because they are newer. Many of the features that exist in the character stream do not exist in the byte stream. For example, using BufferedReader instead of BufferedInputStreams or DataInputStream, using the newLine () method to read the next line, but we need to do something extra in the byte stream.

What is 6.System.out.println ()?

Println is a method of PrintStream. Out is a member variable of a static PrintStream type, and System is a class in a java.lang package that is used to interact with the underlying operating system.

7. What is a Filter stream?

Filter Stream is an IO stream that is mainly used to add additional functionality to existing streams, such as adding lines that do not exist in the source file to the target file, or increasing the performance of the copy.

8. What Filter streams are available?

There are mainly four available filter Stream in the java.io package. Two bytes of filter stream, two characters filter stream. They are FilterInputStream, FilterOutputStream, FilterReader and FilterWriter. These classes are abstract and cannot be instantiated.

Some subclasses of Filter streams:

LineNumberInputStream adds a line number to the target file

Some special methods of DataInputStream, such as readInt (), readDouble () and readLine (), can read an int, double and a string one-time

BufferedInputStream increases performance

PushbackInputStream pushes the required bytes to the system

What is the role of 9.SequenceInputStream?

The purpose of this class is to merge multiple input streams into a single input stream, which is wrapped by the SequenceInputStream class to form a new total input stream. It is very useful when copying multiple files to a single target file. Can be implemented with very little code

10. Talk about PrintStream and PrintWriter.

The two of them have the same function, but belong to different categories. Byte stream and character stream. They all have a println () method.

11. Which stream can be used to improve more performance when copying files?

BufferedInputStream and BufferedOutputStream are used in byte streaming.

In character streams, use BufferedReader and BufferedWriter

12. Talk about pipeline flow (Piped Stream)

There are four types of pipe flows, PipedInputStream, PipedOutputStream, PipedReader and PipedWriter. Pipe flows are useful when passing data in multiple threads or processes.

13. Talk about the File class.

It does not belong to the IO stream, nor is it used for file operations. It is mainly used to know the attributes, read and write permissions, size and other information of a file. Note: great changes have taken place in the file IO in Java7, and many new classes have been introduced to replace the original java.io.File-based file IO operation. For more information, read the following article:

The embrace of Java NIO Path and Files

14. Tell me about RandomAccessFile?

It is a special class in the java.io package, neither an input stream nor an output stream, and it can do both. He is a direct subclass of Object. Generally speaking, a stream has only one function, either read or write. But RandomAccessFile can both read and write files. Some methods of DataInputStream and DataOutStream exist in RandomAccessFile.

The above is all the contents of the article "what are the test questions you often meet with Java IO?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report