Use java. nio. charset. CharsetDecoder to automatically recognize character sets, charsetdecoder
The methods for automatically recognizing character sets that can be found on the Internet are studied. The effective method is to use the third-party class library jchardet. Cpdetector is also used, but jchardet is also us
The Object class is in the Java.lang package and is the ancestor of all Java classes, and each class in Java is extended by it.When defining a Java class, if no indicated parent class i
Java and C ++: Summary of JNI Chinese character string operations
/**** @ Author zosatapo** @ E-mail dertyang@263.net** @ Qq 1670967**/
[Simple problem background]
Java programming sometimes requires JNI for efficiency or other issues. JNI has to faceThe problem is Chinese. (If you are a foreigner and don't care about Chinese construction, you don't need to read
We know that the stream in Java is divided into character stream and byte stream, in which the character stream is mainly for the characters text processing, and the byte stream processing scope is more extensive, after all, pictures, movies, etc. as long as the files are in the form of binary, rather than characters.Character Stream:FileReaderFileWriter.Buffered
data container, a hash table is the purpose.To solve this problem, we can define that the hash table's key value (key) is a character, and the value is the number of occurrences of that character. We also need to scan the string two times from the beginning. When a string is scanned for the first time, the number of occurrences in the hash table is added 1 per scan to a
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 f
Java processing files in the class, stream at the end of the use of byte stream, reader and writer End is a character stream. The difference between the two is read and write, one is read by Byte, and the other is by character.
The bottom of the character stream is the byte
one, byte output streamOutputStream Abstract classThis abstract class is a superclass of all classes that represent the output byte stream. The data of operation is byte, and the basic common function method of output byte stream is defined.
BYTE: This stream only operates 1 bytes in the file at a time
Stream object: When you manipulate files, you do not rely on the operating system
Function: From
decoding, and see where you need to encode in Java:
1:java source code files. When we use the editor to edit data, we need to select a mapping rule to store in the computer when we want to store characters in the editor. When the Java source code is compiled, Javac reads the source code file, gets the byte data of the source code file, and needs to convert it t
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
, sensitive to the case, but the length is not limited, the identifier can take any length of the name;1.4. Keywords cannot be used as identifiers. 2: Keywordshas a special meaning and purpose, can not be arbitrarily used or changed, when we write the program should be careful not to use it as a variable or method name, so as not to cause program compilation errors. keywords in Java : N abstract boolean break byte case
>ca
data operations in the program are in characters (char in Java occupies 2 bytes, C + + char occupies 1 bytes), which requires that we have an IO interface to manipulate characters, To deal with the encoding conversion problem of character and Byte, that is, the write and reader interfaces and their implementation classes, and their class interface diagrams are a
;
Value[i] = C2;
}
}
}
}
return this;
}
This method is defined in the StringBuffer parent class Abstractstringbuilder, so the return value of the method is Abstractstringbuilder, which is invoked in subclasses as follows:
Copy Code code as follows:
Public synchronized StringBuffer reverse () {
Super.reverse ();
return this;
}
From the content of the method, the basic idea in the source code is consistent, the sam
I/O flow
Grouped by data into byte stream and character streams (coded table, Western ASCII, China gb2312 expansion for gbk--> Unified for Unicode--> optimization utf-8)Character streams are based on the byte stream, specifying what table to look forThe flow is divided into input and output streams.Common base class: byte stream InputStream outputstreamCharacte
content.
3.4. handling process
The following two representative examples illustrate how java handles coding problems.
3.4.1. form input
User input * (gbk: d6d0 cec4) browser * (gbk: d6d0 cec4) web server iso8859-1 (00d6 00d 000ce 00c4) class, which needs to be processed in the class: getbytes ("iso8859-1") is d6 d0 ce c4, new String ("gbk") is d6d0 cec4, in
, read the file with the FileInputStream class can specify the encoding read
(3) Java in the output to the System interface (Windows) will be in the memory of variable characters again through the system default language (character set) encoding to convert, so in the output process will also encounter a series of coding problems
3. The solution
(1) SWING/AWT: Ou
specified by the system property User.dir, which is usually the calling directory for the Java virtual machine.That is, relative to the User.dir directory. So we try not to use relative directory, here encountered, so labeled under, understand under.Text output:Java.io.PrintWriterPrints the formatted representation of the object to the text output stream . This class implements all the print methods in Pri
") !=NULL|| Session.getattribute ("Adminid") !=NULL) {//Go to next filterFilterchain.dofilter (request, response); }Else{//Redirect to homepageResponse.sendredirect ("index.jsp");return;//No more filtering to prevent page redirection loops} }@Override Public void Init(Filterconfig arg0)throwsServletexception {}}Web. xml file Configurationfilter> filter-name>LoginFilterfilter-name> filter-class>org.LabReserve.filter.LoginFilterfilt
types into classes, called wrapper classes.Wrapper classes are final types, and they cannot be created as subclasses.A wrapper class is an immutable class, and once an object of a wrapper class is created, the underlying type of
container, the hash table is the purpose.
To solve this problem, we can define that the key value (key) of a hash table is a character, and the value is the number of times the character appears. We also need to scan the string two times from scratch. The first time a string is scanned, the number is added to the corresponding item in the hash table by 1 each time a ch
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.