TitleImportJava.io.BufferedInputStream;ImportJava.io.BufferedOutputStream;ImportJava.io.FileInputStream;ImportJava.io.FileOutputStream;ImportJava.io.FileReader;ImportJava.io.FileWriter;ImportJava.io.IOException;ImportJava.io.InputStream;ImportJava.io.OutputStream;ImportJava.io.Reader;ImportJava.io.Writer;/ * * Filereader/filewriter class * file character input/output stream */ Public class Test03 { Public Static void Main(string[] args)throwsIOEx
* Copy of text files can be achieved using FileReader and FileWriter.* For non-text files (video files, audio files, pictures), only the byte stream can be used!1 @Test2 Public voidTestfilereader () {3FileReader FR =NULL;4 Try {5File File =NewFile ("Dbcp.txt");6FR =Newfilereader (file);7 Char[] C =New Char[24];8 intLen;9 while(len = Fr.read (c))! =-1){TenString str =NewString (c, 0, Len); One System.ou
The code is as follows
Copy Code
More about the content reference
Ps://developer.mozilla.org/en/dom/filereader ">https://developer.mozilla.org/en/dom/filereader
Using Ajax is not directly uploaded files, is generally a new iframe in it to complete the form submission process to achieve the effect of asynchronous upload files.Doing so can achieve better browser compatibility, but the amount of code will be relatively large, even with the use of file upload plug-ins, such as Plupload.
How can you be flexible enough to treat a file as a normal form parameter like a normal AJAX submission form data?
Flash, the use of JavaScript
4 Main methods:Abort (): Interrupt read.Readasbinarystring (): reads the file as a binary code.Readasdataurl (): reads the file as Dataurl.Readastext (): reads the file as text.Event:Onabort: When interruptedOnError: Error whenOnLoad: Read successOnloadend: Read complete regardless of failure or successOnloadstart: Read startOnProgress: in Read2 Properties:Result: The value is only available after the read succeeds, and no is empty.ReadyState:0: for reading data1: Reading2: CompleteHTML5
Brief introduction
With the FileReader object, a Web application can asynchronously read the contents of a file (or raw data buffer) stored on a user's computer, and you can use a file object or a Blob object to specify the files or data that you want to work with. Where the file object can be from a user in a
More than one page, upload multiple pictures demo code
The above is the entire content of this article, I hope to learn JavaSc
Java I/O interpretation and use example
Abstract: This article describes how to interpret and use Java I/O.I. Basic concepts of I/O
The full name of I/O is Input/Output, and Java I/O is the Input and Output operations of Java. Related interfaces and classes are stored in the java. io package. Therefore, you need to import the package during Java input and output operations. Java I/O greatly extends the input and output categories of the system, not o
IO Flow Basic ConceptsIO streams are used to process data transfer between devicesJava's manipulation of data is done in a streaming wayThe objects that Java uses to manipulate streams are on IO packetsStreams are divided into two types by operational data: byte stream and character streamFlows are divided into: input stream, output stream.
Abstract base class for byte streams: inputstream,outputstreamAbstract base class for character streams: Reader,writerNote: The subclass names derived from
);
BufferedReader (Reader in, int bufsize);
For example:
FileReader fr=new FileReader ("D:\1.txt");
BufferedReader buf = new BufferedReader (FR);
BufferedReader provides a readerline () method for reading each line of text.
5, BufferedWriter class
The BufferedWriter class inherits from the writer class, and the BufferedWriter class is used to write data in
data:
Readastext
Reads a file as text, the 2nd parameter is the encoding type, and the default is UTF-8
Abort
Interrupt Read
The following example shows the use of the Readasdataurl method in the FileReader object, with the following code:Tip: The sample code for filesystem in this section is tested under Chrome 28.The
data:
Readastext
Reads a file as text, the 2nd parameter is the encoding type, and the default is UTF-8
Abort
Interrupt Read
The following example shows the use of the Readasdataurl method in the FileReader object, with the following code: Tip: The sample code for filesystem in this section is tested under Chrome 28.The
Introduction: This is Php combined with ajax to Implement Asynchronous file upload.CodeThe instance details page describes PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 334790 'rolling = 'no'>Code example for asynchronous file upload using PHP and Ajax
1: Get the file object2: Read Binary data3: Simulate HTTP requests and send data (t
Python decorator use example and actual application example, python example
Test 1
Deco is running, but myfunc is not running
Copy codeThe Code is as follows:Def deco (func ):Print 'before func'Return func
Def myfunc ():Print 'myfunc () called'Myfunc = deco (myfunc)
Test 2
Call myfunc in the required deco to executeCopy codeThe Code is as follows:Def deco (func
/*======================================================================
A Globalmem Driver As an example of char device drivers
There are two same globalmems in this driver
This example was to introduce the function of File->private_data
The initial developer of the original code is Baohua Song
======================================================================*/
#include #include #include #include #in
();Filereader.onloadend = function () {Console.log (this.readystate); It's supposed to be 2 this time.Console.log (This.result); Read completion callback function, data saved in result}filereader.readasbinarystring (file);//start reading 2 binary data asynchronous parameter to file objectFilereader.readasdataurl (file); Read Base64Filereader.readastext (file);//Read text information
You can run the following simple example (Chrome and Firefox are av
image based on the previous Code:
The Code is as follows:
// Load the image file (url path)Function loadImage (src ){// Filter out non-image filesIf (! Src. type. match (/image .*/)){If (window. console ){Console. log ("the selected file type is not an image:", src. type );} Else {Window. confirm ("only image files can be selected ");}Return;}// Create a FileReader object and call the render function to complete rendering.Var reader = new
I have no intention of seeing a multi-threaded socket server example on the Internet. I think it is very good. In particular, the thread pool is simple and efficient. Although jdk1.5 has already brought its own thread pool package, this code is a good example for learning socket and multithreading.
The following code is a simple arrangement of the example and add
Code:The Code is as follows:// Load the image file (url path)Function loadImage (src ){// Filter out non-image filesIf (! Src. type. match (/image .*/)){If (window. console ){Console. log ("the selected file type is not an image:", src. type );} Else {Window. confirm ("only image files can be selected ");}Return;}// Create a FileReader object and call the render function to complete rendering.Var reader = new Fil
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.