Fadf1th. Encoding of the document1-1 encoding of the file (15:07)2nd. Use of the File class2-1 File Class Common API introduction (10:50)Import Java.io.file;import Java.io.ioexception;public class Filedemo {public static void main (string[] args) {
The byte array input stream creates a byte array buffer in memory, and the data read from the input stream is saved in the byte array buffer. There are several ways to create a byte array input stream Object.The receive byte array is created as a parameter:New Bytearrayinputstream (byte [] a);Another way to create this is to receive a byte array, and two shaping variables off, Len,off represents the first read byte, and Len represents the length of the read Byte.New Bytearrayinputstream (byteint
running the command "FS" to read "is always-1. So in the second while statement, the system jumps out when the first read is executed by the system. Why? -1 is returned for the result of the command. read. So C is not assigned at all, and even if it is assigned a value, C can only hold the next char.As for this solution, the idea is as follows: You read data to an int type variable date in one byte and one byte through the fins. Since date can be printed, it can be assigned to char c, naturally
,A class instance that implements this interface is available for the filter file name.There is only one method under this interface:accept(File dir,String name)Tests whether the specified file should be included in a list of files. : Returns if and only if the name should be included in the list of files true false .Import
Java IO file suffix filtering summary, javaio suffix Filtering
Effect: list specific suffix files under a directory (for example, txt files under the root directory of the D Drive)
Import java. io.
,//stream can manipulate the file object Pro.store (FW, "after Change");}
Iv. Practice
Get the number of uses of an application, more than 3 times, give information about the number of times the usage has been registered, and do not run the program again
Analysis:
This requirement requires a counter, each time the program starts counter into memory, number of times +1, exit program, counter close, store to
2017-10-30The interview in the previous days when the exam two questions, are related to the Java Foundation:
Use Java IO package to read and write files;
Use JDBC to get the data.
It is a pity that I could not remember the basic knowledge, so it is necessary to tidy up and consolidate this knowledge.In this summary, I will summarize the read-wr
(string[] args) { file F=new file ("D:" +file.sep arator+ "test"); F.mkdir ();//Create Folder }} instance Action five: List all files for a specified directory if you now have a directory, you can list the contents of the directory directly. However, there are two methods listed in the File class:
Returned as an array of strings: pub
)======子文件,Java对象======G:\try\123\dsafds.javaG:\try\123\sdafd.javaFive.the name of the output descendant-level directory or file PackageFile;ImportJava.io.File;ImportJava.util.Arrays;/** * output descendant level directory | The name of the file * 1, ListFile () * 2, recursive * * static listroots () root path * @author liguodong */ Public class Demo05 { Pub
optimized to form a UTF-8, one byte in the UTF-8 can not be installed with two, 2 can not be installed with 3 ······. So the problem occurred, when we write Chinese, GBK recognition, but the UTF-8 also identified. However, the binary encoding of the same Chinese Character in the two tables is different, and garbled characters appear. In this case, the ghost stream can be integrated into the internal encoding table, that is, you can specify the encoding table to be checked.
/*** 1. The
Java IO stream: Random file read/write, javaio stream
The Java. io package provides the RandomAccessFile class for creating and accessing random files. Using this class, you can jump to any position of the file to read and write d
IOException Ten: { 11: : Properties Prop = new properties (); : //import Info.txt byte stream information : prop.load (New FileInputStream ("Info.txt")); 16: : //Get program run times : String times = Prop.getproperty ("Times"); 19: : //If first run, set number of times is 1 : if (times = = null) : Prop.setproperty ("Times", "1"); : /
Java IO stream technology-File, javaio
IO stream technology
Concept: input-output:
Input: Read the file to the memory;
Output: write files from memory to other places
Role: mainly solves the problem of data transmission between devices.
Listfiles () of the Files class. For example File[] listFiles(FileFilter filter) , where FileFilter is the filter interface, you need to implement the interface to filter the files.The common filtering method is based on the file name, in fact, also support other filter conditions, such as whether readable, size is greater than 5M, and so on.Import java.io.*;PublicClassFilter1 {PublicStaticvoidMain(string[
Original: Java vs. io and NiO file read/write performance testSource code: Http://www.zuidaima.com/share/1550463508466688.htm1. NIO uses a way closer to the operating system to execute IO: Channels and buffers, as the name implies, data source data is transmitted by the buffer through the channel. 2. After JDK5, the ra
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.