concept for themselves.
Words not much said, on the code:
Import Android.content.Context;
Import Android.util.Log;
Import Java.io.FileInputStream;
Import Java.io.FileOutputStream;
/** * Created by Zhizhao on 2015/11/1 0001 in 16:00.
* * Public class Usingfileinputstream {private context Filecontext; private string fileName; private string fileusername;
Private String Filepassword; Public Usingfileinputstream (String name, context context, string UserName, string password) {this.filename =
This article is based on Linux environment operation, readers need to have a certain knowledge of Linux before readingThe InputStream consists of three methods as follows:
int read (): reads a single byte from the input stream, returning the byte data read (byte data can be converted directly to int type)
int read (byte[] b): reads up to b.length bytes of data from the input stream and stores it in byte array B, returning the actual number of bytes read
int read (byte[] b, int o
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
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
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:
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
InputStream objects created with the FileInputStream class can be used to read content from a file. The two commonly used constructors are as follows: FileInputStream (String FilePath) FileInputStream (File fileobj) Both constructors will throw filenotfoundexception exceptions. Where FilePath is the full pathname of the file, and Fileobj is the file object that
");e.printStackTrace();}System.out.println ();// 例2 – Java中使用FileReader 读取文件数据try (FileReader reader = new FileReader("c:/data.txt")) {int character = reader.read();while (character != -1) {System.out.print (integer.tohexstring (character));System.out.print((char) character);character = reader.read();}} catch (IOException io) {System.out.println("Failed to read character data from File");io.printStackTrace();}}}
Save As UTF-8 output:
12345
UTF-8Efbbbfe6b0b8Feff6c38 Y
construction methods of subclass FileInputStream ⑴, FileInputStream (file file); ⑵, FileInputStream (String name); 2, OutputStream and its subclass FileOutputStream common methods ⑴, class name. write (int c); writes the specified byte to this file output stream. ⑵, class name. write (btye[]b); writes B.length bytes from the specified byte array to this file ou
, FileInputStream needs to invoke the underlying language implementation through native methods.Here's a simple example: Public classfileintest { Public Static void Main(string[] args) throws FileNotFoundException {InputStream is=NewFileInputStream ("F:/shiro-config.ini");intITry{i = is. read (); while(I! =-1) {System. out. println (Char) (i); i = is. read (); } is. Close (); }Catch(IOException E1) {//TODO
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 division of labor.Two relations and differences(1) characters and bytes:The
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 differences(1) characters and bytes:The FileInputStream
by using the file descriptor Fdobj, which represents an existing connection to an actual file in the file system.FileInputStream (String name): Creates a fileinputstream by opening a connection to the actual file, which is specified through the pathname name in the file system.
The following example uses a channel to write a string to a file.
Package Com.bulaoge.alenc;Import Java.io.File;Import Java.io
The fileinputstream and fileoutputstream classes are used to create input stream and output stream objects of disk files, and specify the file path and file name through their constructors. When creating a fileinputstream object instance, the specified file should exist and be readable. When creating a fileoutputstream instance object, if the specified file already exists, the original content of the file w
application, not relative to the file.) such as) so we should create an input class to read the contents of a file, and then create an output class to output the content to the B file. Programming Example: Write a string character to a file with the FileOutputStream class and read the written content with FileInputStream. //filestream.javaimport Java.io.*;public class filestream{ public static void main (
() returns the unique FileChannel object associated with this file output stream. FileDescriptor GETFD () returns the file descriptor associated with this stream. Here is an example of copying an EXE executable file via FileInputStream and FileOutputStream.ImportJava.io.File;ImportJava.io.FileInputStream;Importjava.io.FileNotFoundException;ImportJava.io.FileOutputStream;Importjava.io.IOException;ImportJava
connection to the file and ensures that the Close method of this stream is called when the file output stream is no longer referenced.
FileChannel
Getchannel () returns the unique FileChannel object associated with this file output stream.
FileDescriptor
GETFD () returns the file descriptor associated with this stream.
void
Write (byte[] b) writes B.length bytes from a specified byte array to this file output stream.
void
Java FileOutputStream ClassJava FileOutputStream is an output stream for writing data to a file.If you had to write primitive values then use Fileoutputstream.instead, for character-oriented data, prefer FILEWRITER.BU T can write byte-oriented as well as character-oriented data.Example of Java FileOutputStream class
Import java.io.*;
Class test{
public static void Main (String args[]) {
try{
FileOutputStream fout=New FileOutputStream ("Abc.txt");
String s="Sachin Tendulkar is my
);//write the string into the file}Catch(IOException e) {System. out. println ("Error"+E); } }}Example: Copying a file to another fileImportJava.io.File;ImportJava.io.IOException;ImportJava.io.FileOutputStream;ImportJava.io.FileInputStream; Public class test{ Public Static void Main(String args[])throwsIOException {Try{File FromFile =NewFile ("A.txt"); File ToFile =NewFile ("B.txt"); FileInputStream
what is InputStream and OutputStream.
InputStream and OutputStream are abstract classes that are the parent class for all byte input and output streams. Here, we first need to clarify two concepts: InputStream (Input stream): the input stream is used to read data. --> > > Read outputstream (Output stream): Output stream is used to write data. --> > > Write file input stream--fileinputstream
FileInputStream
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.