";
Switch (status) {case
"Ordercancel":
System.out.println ("Cancellation of Order");
break;
Case "ordersuccess":
System.out.println ("successful booking");
break;
Default:
System.out.println ("status Unknown");
4.try-with-resource
Try-with-resources is a try declaration that defines one or more resources, which is the object that the program needs to close after it has finished processing it. Try-with-resources ensure tha
determines that this object is not referenced. It is defined in the object class, so all classes inherit it. Subclass overwrites the finalize () method to sort system resources or perform other cleanup tasks. The finalize () method is called before the Garbage Collector deletes an object.
18. Give up to five common classes, packages, and interfaces.A: common classes: bufferedreader, bufferedwriter, filereader, filewirter, and string.Common packages:
(String [] args) throws IOException {System. out. println (the receiving end has been started); while (true) // the receiving end has been started {// 1, and the socket service has been established; new DatagramSocket ds = new DatagramSocket (12000); // 2, create a packet package byte [] buf = new byte [1024]; DatagramPacket dp = new DatagramPacket (buf, buf. length); // 3, receives data packets ds. receive (dp); // 4, read the content in the package String ip = dp. getAddress (). getHostAddres
Address: http://blog.csdn.net/kongxx/article/details/7259436
Currently, there are fewer and fewer cases of using Socket directly in Java, because there are many options available, such as spring, which can support many remote connection operations, in addition, the remoting of JBoss is also a good choice, as well as Apache Mina, etc. However, in some special cases, it still cannot escape the situation of writing socket directly, such as some inexpli
decompress the command.
After these two commands are executed, an abc folder will appear in the current folder.If your system supports the tar-z command
If your system level is higher, you don't have to worry about it. The tar command can directly perform operations on gz:
Tar-zxvf compressed file name .tar.gz => This command can directly decompress the compressed file tar-zcvf compressed file name .tar.gz compressed file name => This command can directly compress tar.gzFile handle occupation c
Java Stream and JavaStream
1. Read console input
The Java console input is completed by System. in. To obtain a consumer stream bound to the console, you can wrap System. in A BufferedReader object to create a consumer stream. The syntax for creating a BufferedReader is as follows:
can specify the nature of the file to be opened: R, read-only; W, write-only; RW, read/write
3) You can directly jump to the specified position in the file.
4. An example of an I/O Application
Import java. Io .*;
Public class testio {
Public static void main (string [] ARGs)
Throws ioexception {
// 1. read data from a file in behavior units
Bufferedreader in =
New
jump to the specified position in the file.4. An example of an I/O ApplicationImport java. Io .*;Public class testio {Public static void main (string [] ARGs)Throws ioexception {// 1. read data from a file in behavior unitsBufferedreader in =New bufferedreader (New filereader ("F: \ nepalon \ testio. Java "));String S, S2 = new string ();While (S = in. Readline
-only; W, write-only; RW, read/write
3) You can directly jump to the specified position in the file.
4. An example of an I/O Application
Import java. Io .*;
Public class testio {
Public static void main (string [] ARGs)
Throws ioexception {
// 1. read data from a file in behavior units
Bufferedreader in =
New bufferedreader (
New filereader ("F: // nepalon // tes
Abstract: At first, Java does not support text file processing. In order to make up for this defect, two classes, reader and writer, were introduced. These two classes are abstract classes, in writer, the write (char [] CH, int off, intlength), flush (), and close () methods are abstract methods. In reader, read (char [] CH, int off, int length) and close () are abstract methods. Subclass should implement them separately. When reading and writing text
)Create a FileInputStream by opening a connection to the actual file, which is specified by the pathname name in the file system.Reader|--bufferedreader|___inputstreamreader|__filereaderBufferedReader: Reads text from the character input stream, buffering individual characters, enabling efficient reading of characters, arrays, and rows.Construction Method SummaryBufferedReader (Reader in)Creates a buffered character input stream that uses the default
Address: http://blog.csdn.net/kongxx/article/details/7259465
One of Java Socket practices: Single-thread Communication
PreviousArticleSpeaking of how to write a simplest Java Socket communication, but one problem in the previous article is that the server can only accept one client request, which occupies this position after the first client connection, later, the client cannot continue to connect, so s
Java is super simple to send emails (dynamic control of the number of recipients), java sends emails
Email sending implementation
The following rack packages need to be introduced in advance, the most important rack package is jodd-3.7 this
Above frame package: http://pan.baidu.com/s/1kVs7Tyv extraction password: h22x
A new utilcategory is created, in which emails.txt is used to dynamically configure the
); FileInputStream fis = new FileInputStream (f); PrintWriter pw = new PrintWriter (new OutputStreamWriter (FOS, "utf-8")); BufferedReader br = new BufferedReader (new InputStreamReader (FIS, "utf-8"));} catch (Exception e) {e.printstacktrace ();}With the above code, we implemented the use of wrapper classes and the use of our specified character encoding scheme for more convenient character manipulation.Fo
Java -- Method for retrieving data input from the console, java Console
1. Use the standard input string System. in
System. in. read (); // read-only data in one byte at a time, but we often want to obtain a string or a group of numbers.
2. Use numeric to obtain a string or a group of numbers
// The next () method of substring is used to obtain the user input string; nextInt () converts the obtained input
Use of Java-BlockingQueue, java-blockingqueue
Every time I write something in my blog after a long time, I can say that I am busy. This is an excuse for myself. In fact, I am still lazy. Ah...
There is a need for comparison in recent projects. You need to obtain the parameters from the log file, and then call different APIs to compare the results. But I don't know how to use it, so I checked the jdk manual
This article describes in detail how to upload and download multimedia files through java development, if you are interested, you can refer to the scenarios where media_id is required to reply images, audios, and video messages. Therefore, you must Upload multimedia files to the server.
To upload multimedia files to the server and download files from the server, see: http://mp.weixin.qq.com/wiki/index.php? Title = upload and download multimedia files
initiative to close connected sockets, and close the listening socket in a proper place.
The server should receive messages cyclically.
Simple Client:
Import java. io. IOException; import java. io. outputStream; import java.net. socket; public class TCPClient {public static void main (String [] args) {// 1. create client Socket c_sock = null; OutputStream client_outstream = null; try {c_sock = new Socket (
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.