The purpose of the File API is to provide Web developers with a secure way to access files on the user's computer and to perform operations on them better.
HTML5 Although it allows us to access the local file system, files can only be read to the file API if the user triggers the read behavior, which usually occurs when the form file is selected and dragged.
I. Compatibility of the File API
The File API support in major mainstream browsers is shown in the following illustration:
Note: Pictur
, and when it is reduced to 0 o'clock, a batch of data is taken from the source into the buffer.Content to complement:MybufferedreaderLineNumberReader: You can define line numbers.---------Character Stream:FileReaderFileWriterBufferedReaderBufferedWriterBYTE stream:InputStream OutputStream.The byte stream object that operates the file.FileOutputStreamFileInputStreamBufferedoutputstreamBufferedinputstreamThe conversion action between a character stream and a byte stream.----------Conversion Flow:
to facilitate more intuitive data operations. There are two main types of file content operations: traffic flow and word throttling.
(1) The byte stream has two abstract classes: InputStream OutputStream and its corresponding sub-classes include FileInputStream and FileOutputStream for file read and write. BufferedInputStream and BufferedOutputStream provide the buffer function.
(2) The primary stream has two abstract classes: Writer Reader and its corresponding sub-classes FileWriter and
in the Fw.flush ();
catch (IOException e) {e.printstacktrace ();
finally{try {if (fw!=null) {//Close the stream resource, but the data in the internal buffer is refreshed once before it is closed fw.close ();
}}catch (IOException e) {e.printstacktrace ();
}
}
}
}
Print Java File source code demo code:
package javase.day18;
Import Java.io.FileReader;
Import java.io.IOException; public class Filereadertest {public static void main (st
("for (int i=0;iif (ListOut.println (List}}%>
Determine if a blank fileString Path=request.getrealpath ("/");OUT.PRINTLN (path);FileReader fr=new FileReader (path + "\\AtEnd.txt");//Create the FileReader object and instantiate it as FRObjects generated by the FileReader class use the Read () method to read and remove
A character stream is optimized for character data, thus providing some useful character-oriented characters, the source or target of which is usually a text file. Reader and writer are the parent classes of all character streams in the java.io package. Because they are abstract classes, you should use their subclasses to create entity objects that use objects to handle related read and write operations. The subclasses of reader and writer can be divided into two broad categories: one for readin
objects representing all the files in the directory
Out.println ("for (int i=0;iif (ListOut.println (List}
}
Out.println ("for (int i=0;iif (ListOut.println (List}
}
%>
determine if a blank fileString Path=request.getrealpath ("/");
OUT.PRINTLN (path);
FileReader fr=new FileReader (path + "//atend.txt");//Create the FileReader object and instantiate it as F
Io (input and output) operations in java (1), iooutputIO, short for Input and Output. In java, IO involves a large range. Here we mainly discuss the reading and writing of file content.Other knowledge points will be placed in subsequent chapters (I think the article is too long and no one has the patience to go to the end)There are two main types of operations on file content: They are: Ghost stream Byte stream The volume stream has two abstract classes: Writer Reader.The corresponding sub-cl
IO, short for Input and Output. In java, IO involves a large range. Here we mainly discuss the reading and writing of file content.
Other knowledge points will be placed in subsequent chapters (I think the article is too long and no one has the patience to go to the end)
There are two main types of operations on file content: They are: Ghost stream Byte stream The volume stream has two abstract classes: Writer Reader.The corresponding sub-classes FileWriter and
There are several common methods to read and write files:1. Byte read/write (InputStream/OutputStream) and character read (FileReader/FileWriter)FileInputStream's read (buffer) method, each time from the source program file OpenFile. java reads 512 bytes, stores them in the buffer, and then displays the new String (buffer) constructed with the buffer value on the screen. For example, the program is shown in biz.1cn.stream. create the testfile.txt
Auto-generated catch block22 e.printStackTrace();23 } 24 }25 }
We recommend that you first create a file reference and then use exists () to check whether the file exists. This is faster than the annotated code to directly throw an exception, when using this function, you must close the file input stream.
FileReader or InputStreamReader is used to read the bytes of a single character
The file API in HTML 5 is a big bright spot in HTML 5 that lets us read local files. Let all developers sigh! Multiple Access file interfaces are provided through the file API specification.
Browser support for file-related interfaces in HTML 5
When using the file API, you may need to detect browser support, and the feature detection code is as follows:
CopyDetects if the browser supports the file API-related interfaces.if (window. File window. Fi
There are several common methods for reading and writing Java files, such as InputStream/OutputStream and BufferedReader, I will introduce their usage examples in detail below.
There are several common methods to read and write files:
1. byte read/write (InputStream/OutputStream) and character read (FileReader/FileWriter)
FileInputStream's read (buffer) method, each time from the source program file OpenFile. java reads 512 bytes, stores them in the b
ChingOriginal address: http://blog.csdn.net/qingdujun/article/details/41154807This article company explains FileWriter, FileReader, Bufferwriter, Bufferreader, Linenumreader, FileOutputStream, FileInputStream, Bufferinputstream, Bufferoutputstream and other flow operation technology.1. Write File FileWriterThe difference between flush () and close ():1) Flush () flushes the stream, writes the data to the file, and the stream can be used;2) Close () au
Method name
Description
int read ()
Reading a single character from the input stream
int read (byte[] c)
Reads C.length-length characters from the input stream, saves to character array C, returns the number of characters actually read
Read (char[] c,int off,int len)
A length character that reads up to Len from the input stream, is saved to the character array C, and the saved position starts at the off position, r
flow, the essence of the flow is data transmission, according to the data transmission characteristics of the stream abstracted into various classes, convenient and more intuitive data manipulation. There are two main types of operations for file content: character stream and Byte stream(1) Byte stream has two abstract class: InputStream outputstream its corresponding subclass has FileInputStream and FileOutputStream realize file reading and writing. The Bufferedinputstream and Bufferedoutputst
Reader:Sub-class for reader:1.BufferedReader :FileReader does not provide the ability to read lines of text, BufferedReader can specify the buffer size, wrapping the Read method to efficiently read the character stream. Provides efficient reading of characters, arrays, and rows.开发文档中的介绍:Reads text from the character input stream, buffering individual characters, enabling efficient reading of characters, arrays, and rows. You can specify the size of th
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.