In Java, besides binary files and text files, there are Data-based Data operations. Data here refers to the basic Data types and strings of Java. Basic data types include byte, int, char, long, float, double, boolean, and short.Speaking of the basic data types of Java, two classes must be mentioned: DataInputStream and DataOutputStream. They provide operations on
1. Use the print stream to improve the case for copying a text file2. code example:1 Packagecn.itcast_03;2 3 ImportJava.io.BufferedReader;4 ImportJava.io.BufferedWriter;5 ImportJava.io.FileReader;6 ImportJava.io.FileWriter;7 Importjava.io.IOException;8 ImportJava.io.PrintWriter;9 Ten /* One * Requirements: Datastreamdemo.java copied to Copy.java A * Data Source: - * Datastreamdemo.java--read data--fileread
1. Store the data in the collection into a text file case:Requirement: To store string data in the ArrayList collection into a text file?(1) Analysis:Through the meaning of the topic, we can know some of the following things,A string is stored in the ArrayList collection.Traverse the ArrayList collection to get the data.It is then stored in a text file.The text file description uses a character stream .(2)Data Source :ArraylistDestination :A.txt--File
to:A.txt+b.txt+c.txt--d.txt1 public Static voidMain (string[] Args)throwsIOException {2 //Sequenceinputstream (enumeration E) needed is enumeration3 //and enumeration is the return value type of a method in a Vector. enumeration4 //so it's going to be the way. 5 6 //first, Define a vector object7VectorNewVector();8InputStream I1 =NewFileInputStream ("pw.txt");9InputStream i2 =NewFileInputStream ("user.txt");TenInputStream i3 =NewFileInputStream ("datastreamd
In Java, in addition to binary files and the use of text files, there is data based operations, where data refers to the Java basic data types and string. Basic data types include byte, int, char, long, float, double, Boolean, and short.
When it comes to Java's basic data types, the two classes that must be mentioned are DataInputStream and DataOutputStream. They provide operations on
1. There are often many problems when developing (these exceptions are not provided in the Java Internal system framework)For example, the test results must be between 0~100.Obviously Java has no corresponding exception, we need to do an exception ourselves .(1) Inherit from exception (compile period)(2) inherit from RuntimeException (running period)2. Examples of custom exceptions:(1) Custom exception myex
5 7
Print numbers greater than 5: 6 7
The following example uses a LAMBDA expression to print the square of each element in a numeric value, and note that we use the. Stream () method to convert a regular array to a stream. Java 8 adds some awesome streaming APIs. The Java.util.stream.Stream interface contain
In the blink of an eye application upgrade JDK8 has been a few months, the Lambdas expression and Streams APIs did bring the students to the programming efficiency and code readability of the promotion, the code becomes more concise and direct, more in line with human thinking (it seems that the development of programming language is also the spirit of "people-oriented" thinking). ATA on the two new features of the article has been a lot of, immortal everyone eat almost, often home side dishes,
. (father is broken, son can not be worse than father)Ten * B: If the parent throws multiple exceptions, the subclass overrides the parent class and can only throw the same exception or a subset of his, the subclass cannot throw exceptions that the parent class does not have. (father is broken, son can not be worse than father) One * C: If the overridden method does not throw an exception, then the method of the child class is absolutely not to throw an exception, if there is an exception in the
inputstreamreader reading Data █InputStreamReader Read Data method ? public int read (); Reads a single character. ? public int Read (char[] cbuf); Reads a character into an array. ? public int Read (char[] cbuf,int off, int len); Reads a character into a part of the array.
public static void Main (string[] args) throws IOException {FileInputStream fis = new FileInputStream ("1.txt"); InputStreamReader ISR = new InputStreamReader (FIS);//Does not spe
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.