the lang of the operating system.When the bytes stream is actually converted into byte,The same applies to byte [] String. getBytes (String charsetName ).Java example:IO is divided into two streamsByte stream InputStream OutputStreamStream Reader WriterThey are all abstract classes.ImplementationByte stream FileInputStream FileOutputStreamStream FileReader FileWriterYou can use InputSteamReader OutputStreamWriter to convert byte streams into bytes st
queued after the subclass exception catch blockAccess exception informationThe program needs to access information about the exception object in the catch block, which can be obtained by accessing the exception parameter after the catch block, and when the Java runtime decides to call a catch block to process the exception object, the exception object is assigned to the exception argument after the catch block (that is, the formal parameter of the exception type). The program can use this param
contain multiple exception types, each type is separated by a | number, and the variable E with multiple exceptions has an implicit final decoration, so it cannot continue to be assigned.4 , exception information access:A, GetMessage (): Returns the detailed description string for the exception.B, Printstacktrace (): Outputs the trace stack information of the exception to the standard error output.C, Printstacktrace (PrintStream s): Outputs the trace stack information of the exception to the sp
operates the data unit to be different, in which InputStream and the reader all is abstracts the data as a water pipe, the program may through the read () method each time extracts one "drops", also may pass read (char[] cbuf) method to read a plurality of "water droplets", which are returned by the read () method to determine whether the end point of the input stream has been made.eg. read the file, the number of characters in the statistics file:public class Filedemo{public static void Main (
Author: gnuhpcSource: http://www.cnblogs.com/gnuhpc/
A jar file is a zip file with a specific structure.
1. Create a jar file:
Import java. util. Jar. jarentry;Import java. util. Jar. jaroutputstream;Import java. util. Jar. manifest;Import java. Io. file;Import java. Io. fileoutputstream;Import java. Io. fileinputstream;Import java. Io. ioexception;Public class jarcreate {Public static void main (string Arg []) {Jarcreate ZC = new jarcreate ();ZC. Cre
I,
Summary 1
1. Read File Content by byte
2. Read File Content by character3. Read File Content by row
4. Randomly Read File Content
Public class readfromfile {/*** reads files in bytes. It is often used to read binary files, files, sounds, images, and other files. */Public static void readfilebybytes (string filename) {file = new file (filename); inputstream in = NULL; try {system. out. println ("Read File Content in bytes, one byte at a time:"); // read one byte at a time in = new
Byte-based IO operation interface
Character-based IO operation interface
The data persistence and network transmission of character and byte conversion interfaces are performed in bytes. Therefore, conversion from character to byte or from byte to character is required.
InputStreamReader is a bridge between byte and character conversion. The encoding character set must be specified during the process from InputStream to Reader. StreamDecoder is the OutputStreamWriter class that imple
. Stored in the/data/package name/files Folder
Usage
It still needs to operate the File through FileInputStream and FileOutputStream, but not through their construction methods.
Get FileInputStream
FileInputStream FCM = openFileInput (); (Activity method)
FileOuputStream fos = openFileOutput (); (Activity method)
File will be automatically created
External SDCa
[Switch] the correct method for obtaining the file size in Java, java for obtaining the file size
Source: http://blog.csdn.net/chaijunkun/article/details/22387305. I will sort out relevant blog posts from time to time and improve the relevant content. Therefore, we strongly recommend that you view this article in the original source.
When writing code today, You need to implement the function of obtaining the File size. Currently, there are two implementation methods: the length () method of Fi
data using the Write method of FileOutputStream, although it receives an int type of data, it really writes only one byte of data, justWrite down eight bits of binary data, and all other 24 bits of data are discarded.00000000-000000000-00000001-11111111 51111111111--->-1Exercise: Copy files to a different path:import java.io.file;import java.io.fileinputstream;import java.io.fileoutputstream;import java.io.IOException;/*requirement: Copy a picture. */ Public classCopyimage { Public Static voidM
output streamThe input stream can only be read, the output stream can only write, and the program needs to use different streams depending on the characteristics of the data being transmitted.Input byte stream InputStream
InputStreamis the parent class for all input byte streams, which is an abstract class.
ByteArrayInputStream, StringBufferInputStream FileInputStream is three basic media streams, which Byte 数组 StringBuffer read data fro
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.