Import java.io.*; public class Filereadersample {public static void main (String args[]) throws IOException {//Create an array that can hold 1024 characters Char Data[]=new char[1024]; Establish object Fr FileReader fr=new filereader ("C://java//donkey.txt"); Read the data into the character list, int num=fr.read (data); Converts a list of characters to a string Str=new string (data,0,num); Outp
File, fileinputstream, filereader, inputstreamreader, bufferedreader...
References:
L Chapter 12 of core Java
L detailed description of how to operate text files using Java
Http://java.ccidnet.com/art/3737/20041108/523627_1.html
L what is filereader class? What is the difference with fileinputstream ???
Http://book.hackbase.com/ask2/ask107572.htmOrganize and comprehend by yourself:Introduction:C language on
() causes the byte to be read from the file and converted to a character to return, which is extremely inefficient.
You can use BufferedReader to specify the size of the buffer, or you can use the default size. In most cases, the default value is large enough.
Therefore, it is recommended to use BufferedReader to wrap all Reader (such as FileReader and InputStreamReader) whose read () operation may be expensive.
For
Use and difference of fileinputstream, filereader, inputstreamreader file, fileinputstream, filereader, inputstreamreader, and bufferedreaderReferences:Chapter 12 of core JavaDetailed description of http://java.ccidnet.com/art/3737/20041108/523627_1.html using Java to operate text filesWhat is filereader class? What is the difference with fileinputstream ???Http:
InputStreamReader when you want to specify the encoding methodclass, while the parameters and FileInputStream of the FileReader constructorAs a file object or a string representing path, you can see that the filereader is used when you want to read a document according to the files object or string;I think the role of FileReader sub-category is the small divisio
to specify the encoding methodclass, while the parameters and FileInputStream of the FileReader constructorAs a file object or a string representing path, you can see that the filereader is used when you want to read a document according to the files object or string;I think the role of FileReader sub-category is the small division of labor.Two relations and dif
data.Previewing a picture file using the FileReader methodIn the previous instance, the Blob interface allows access to file data blocks for file-related information. However, if you want to read the file, you also need to read the data into memory or page through the method in the FileReader interface, for example, the small size picture file, you can get the f
Transferred from: Http://hi.baidu.com/danghj/item/0ef2e2c4ab95af7489ad9e39Resources:L "Core Java" chapter 12L How to manipulate text files using Java http://java.ccidnet.com/art/3737/20041108/523627_1.htmlWhat kind of FileReader is L? What's the difference with FileInputStream? Http://book.hackbase.com/ask2/ask107572.htmSelf-collation and understanding:Introduction:C language only needs a file*, and unlike C, Java has a series of flow types, the numb
Differences between fileinputstream and filereader
Core tips: 1) File class introduction File class encapsulates the function of operating the file system on the user's machine. For example, you can use the File class to obtain the last modification time, move the object, or delete or rename the object. In other words, the stream class focuses on the file content, while the file class focuses on the main
Successfully read
Onloadend
Read complete regardless of successful failure
3, the use of FileReader interfaceDetermine if the browser supports the FileReader interface if (typeof FileReader = = ' undefined ') { result. Innerhtml= "function Readasdataurl () { //Check whether the image file is var, filename = doc
File, [encoding]
Read a file as text
ReadAsText:The method has two parameters, the second is the text encoding method, the default value is UTF-8. This method is very easy to understand. It reads the file as text, and the read result is the content in the text file.ReadAsBinaryString:This method reads a file as a binary string, which is usually transmitted to the backend. the backend can store the file through this string.ReadAsDataURL:This is the method used in the
as Dataurl
Readastext file, [encoding] reads files as text
Readastext: The method has two parameters, where the second parameter is the encoding of the text, and the default value is UTF-8. This method is very easy to understand, the file is read in text mode, the result of reading is the content of this text file.readasbinarystring: This method reads a file as a binary string, usually we pass it to the back end, and the backend can store the file through this string.Readasdataurl: Thi
Dataurlreadast ext file, [encoding] reads the file as text Readastext: The method has two parameters, where the second parameter is the encoding of the text, and the default value is UTF-8. This method is very easy to understand, the file is read in text mode, the result of reading is the content of this text file. Readasbinarystring: This method reads a file as a binary string, usually we pass it to the back end, and the backend can store the file through this string. Readasdataurl: This is th
not support mark (), or some other I/O error occursResetpublic void Reset ()Throws IOExceptionResets the stream. If the stream is marked, try repositioning the stream at that mark. If the stream is marked, an attempt is made to reset the stream in a way that is appropriate for a particular stream, for example, by repositioning the stream to its starting point. Not all character input streams support the reset () operation, and some support reset () a
Abort
None
Interrupt Read
Readasbinarystring
File
To read a file as a binary code
Readasdataurl
File
Read the file as Dataurl
Readastext
file, [encoding]
To read a file as text
Readastext: The method has two parameters, where the second parameter is the encoding of the text, and the default value is UTF-8. This method is very easy to understand, the file is read in text mode, t
.
JavaScript
In this example, we use the input form field to upload an image. When you select an image on your computer, the image will be displayed on the page:
Document. getElementById ('upload-file '). addEventListener ('change', function () {var file; var destination = document. getElementById ('destination'); destination. innerHTML = ''; // loop the multiple objects selected by the user for (var x = 0, xlen = this. files. length; x
In this
This article refers to: http://blog.csdn.net/jackfrued/article/details/8967667One: FileReaderFileReader is an important member of the API to read the file, the FileReader interface provides a way to read the file and an event model containing the results of the read event;Two: The method of FileReader eventThe FileReader instance has 4 methods, 3 of which are use
Dataurlreadast ext file, [encoding] reads the file as text Readastext: The method has two parameters, where the second parameter is the encoding of the text, and the default value is UTF-8. This method is very easy to understand, the file is read in text mode, the result of reading is the content of this text file. Readasbinarystring: This method reads a file as a binary string, usually we pass it to the back end, and the backend can store the file through this string. Readasdataurl: This is th
FileOutputStream corresponds to FileWriter: Converts a stream of bytes into character streams, where data written to OUT1 is automatically converted to characters by Byte. See more highlights of this column: Http://www.bianceng.cnhttp://www.bianceng.cn/Programming/Java/FileWriter out1 = new FileWriter
(file);
Writes 10 Kanji out1.write ("Byte flow is example of character stream");
Write to "0123456789" + newline character
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.