Compare the performance of new and old java I/O-Take copying large files as an Example
Package newio; import java. io. *; import java. nio. byteBuffer; import java. nio. channels. fileChannel;/** use APIs of the New and Old I/O packages respectively to copy files, and compare performance */public class CopyFileCompara {public void copyFileOld (File from, File) throws IOException {// use the traditional I/O Stream processing (with a buffer mechanism) FileInputStream fin = new FileInputStream (fro
socket function fails to be created, a socket will be thrown. error exception, need to capture: # handling errors in python socket programs import socket # for socketsimport sys # for exit try: # create an AF_INET, STR EAM socket (TCP) s = socket. socket (socket. AF_INET, socket. SOCK_STREAM) Doesn't socket. error, msg: print 'failed' to create socket. error code: '+ str (msg [0]) +', Error message: '+ msg [1] sys. exit (); print 'socket Created 'so
main functions are running on our native programs, such as Word, Excel and other applications running on this computer belong to the desktop application.
2: Enterprise-class applications
First explain the enterprise application: The simple is the large-scale application, the general use of more people, the large amount of data, the stability of the system, security, scalability and the availability of high requirements.
This is one of the most widely used areas of Java, and a
anomaliesException for the program, in the usual, and then in fact the exception code is very high, because it needs to collect the field data StackTrace. However, there are some measures to avoid exception throws, that is to do some early check.For example, we want to print a file of each line of string, did not do check the code below, is the existence of filenotfoundexception thrown possible.Privatevoid printfilebyline (String FilePath) {try {fileinputstream InputStream = new FileInputStr
/** Clientsocket Communication Class **/public class Clientsocket { /** server address */ private String serverurl= "192.168.124.214"; /** server port */ private int serverport=8888; /* Send command thread */ class Sendcommandthread extends thread{ N Bsp private string command; public sendcommandthread (string acommand) { nbsp This.command = acommand; } public void run () { N Bsp try{ socket socket = new Socket (ServerURL , ServerPort); printwriter out = new Prin
on Demand 132 * Absolute path or relative path, if it is relative path, then from the current project under the directory start calculation, 133 * such as: The current project path/config/config. Properties, 134 * Relative path is config/config.properties 135 * 136 * @param filePath13 7 * @return void138 * @throws139 */140 public static void Getproperties_2 (String filePath) {141 Properties prop = new properties (); 142 try {143//Read configuration file via input buffer stream 144 Input
Reprint Please specify source: http://blog.csdn.net/zhaokaiqiang1992As to what is serialization, and why the knowledge of serialization is no longer elaborated, this article mainly discusses some special points of the situation.How to achieve serialization and deserialization in 1.javaThe following code is a simple instance of serializationpublic static void Main (string[] args) {System.out.println ("-----------------serialization----------------------↓"); Student student1 = new Student ("Zhao")
) {this.username = UserName;} Public String GetPassword () {return password;} public void SetPassword (String password) {this.password = password;} public int getage () {return age;} public void Setage (int.) {this.age = age;}}Serializationdemo.java Package com.huowolf.api;/* * Requirements: Create file "User.txt" in D drive Application object serialization knowledge to save the user information to a file, * After the object is read into the modified password after the file is written back (u
Generator
If you're tired of Lorem ipsum generators, you can randomly generate text through this English false-sentence generator, which has been studied for years and can enhance the design effect, and users can set the number of text paragraphs to produce.
Example (English):
Around the world, we'll find a pot of the gold just sitting where the rainbow ' s ending. Time–we ' ll fight against the time, and we'll fly on the "white Wings of the" wind. The around of the world, no we won ' t say
.
To reduce the file size:
1. Please select "file" > "Reduce File Size".
2. Please select the compatible version you want, and then click OK.
Note: If you select Acrobat 4.0 and newer versions, and the document contains transparency, transparency will be flattened.
PDF documents from some databases are often large in size, such as the APS download a EAM article http://prola.aps.org/abstract/PRB/v29/i12/p6443_1
Because the file is an image, not
out the data
Server code
Package capitalsocket;
Import Java.io.BufferedReader;
Import java.io.IOException;
Import Java.io.InputStreamReader;
Import java.net.InetAddress;
Import Java.net.ServerSocket;
Import Java.net.Socket;
public class Capitalizeserver {private static int clientnum = 0; public static void Main (String args[]) throws Exception {ServerSocket listener = new ServerSocket (9898, 0, Inetadd
Ress.getbyname ("192.168.1.168")); try {while (
objectoutputstream; public void Save () throws IOException {FileOutputStream fout = new Fileoutputstr
EAM ("E:\\obj");
ObjectOutputStream oout = new ObjectOutputStream (fout); Oout.writeobject (this);
Oout.close ();
Fout.close (); ///deserialization///primary use to ObjectInputStream public static serializableobject load () throws IOException, Classnotfoundexceptio
n {fileinputstream fin = new FileInputStream ("E:\\obj");
ObjectInputStream oin
Copy Code code as follows:
Webfolder= "/"
host= "index_cn.asp" ' foreground dynamic address
Folder= "/" folder
Filename= "index_cn.html" generates a static filename
Fso_info Host,folder,filename
Response.Write "Generate Web site Chinese home static HTML complete. ' Generate HTML
Function Fso_info (Host,folder,filename)
host= "http://" +request.servervariables ("Http_host") webfolderhost
If SaveFile ("folderfilename" "," "host") Then
Response. The Write "folderfilename" build succee
above code, we used the custom class RedisCacheOptions as the Redis configuration information class, and in order to implement the Poco configuration definition, we also inherited the IOptions interface, which is defined as follows:
public class rediscacheoptions:ioptions
The third section defines the cache context class that is used when the delegate is invoked CacheContext , as follows:
Using Microsoft.Framework.Cache.Distributed;
Using System;
Using System.IO; namespace Mi
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.