-points that are said here can be n threads, or the n execution steps of a 1-line thread. When using multiple threads, you only need to pass the Countdownlatch reference to the thread.Other methodsIf there is a parsing sheet thread processing is slow, we cannot let the main thread wait, so we can use another await method with the specified time, await (long time, timeunit unit): This method waits for a certain period, The current thread is no longer blocked. Join also has a similar approach.Note
The following code mainly calls 2 common functions of the tool class, Singletonlist and EmptylistString[] init = {"One", "one", "three", "one", "one", "three"}; List List = new arraylistThe list that they return is immutable. Singletonlist has only one element and is final. private static Class SingletonlistFor Emptylist public static final List empty_list =
this.totalcount;}/*** Total Pages taken*/Public long Gettotalpagecount () {if (totalcount% pageSize = = 0)return totalcount/pagesize;Elsereturn totalcount/pagesize + 1;}/*** Data Capacity per page*/public int getpagesize () {return pageSize;}/*** Records in the current page*/Public Object GetResult () {return data;}/*** Take the current page number, page number starting from 1*/public int Getcurrentpageno () {return start/pagesize + 1;}/*** Do you have the next page?*/public Boolean hasnextpage
Encapsulates common reflection-related methodspublic class Reflectutil {/** * gets class through Classpath * * @author lhy Java Reflection Tool Class encapsulation
//the tool class can be implemented by automatically generating the corresponding Java entity class given a specified database table name.
Package com.iamzken.utils;
Import Java.io.BufferedWriter;
Import Java.io.File;
Import Java.io.FileWriter;
Import java.io.IOException;
Import Java.net.URL;
Import java.sql.Connect
The example is how to convert a Student object to a JSON string, and in practice we can convert any Java class to a JSON string, and the implementation is very simple, you just need to create an Gson instance, then pass the object that will be converted to the JSON string, and invoke the instance's ToJ Son method. Import Com.google.gson.Gson;Import Java.util.Calendar;public
1. The tool class method for using the INT data when transferring data using the TCP protocolConvert Int data to byte arraypublic static byte[] Inttobytearray (int data) {Byte[] result = new BYTE[4];Result[0] = (byte) ((Data >>) 0xFF);RESULT[1] = (byte) ((Data >>) 0xFF);RESULT[2] = (byte) ((Data >> 8) 0xFF);RESULT[3] = (byte) (Data 0xFF);return result;}Converts a 4-byte array of bytes into Int datapubli
Sequenceinputstream can be seen as an ordered set of multiple inputstream objects. When the data of an inputstream object is read, it automatically retrieves the next inputstream object for reading until all the inputstream objects are read.
With this feature, we will compile a file splitting and merging tool.
Instructions for use:
Sequencedemo [Option] [filepath] [number]
Option:
-C: indicates the file to be merged.
-S: indicates the file to be spli
=null; Bufferedoutputstream Outbuff=null; try {file sourcefile = new File (SourcePath); File TargetFile = new file (TargetPath); if (!targetfile.exists ()) {Targetfile.getparentfile (). Mkdirs (); }//Create a new file input stream and buffer it inbuff=new bufferedinputstream (new FileInputStream (sourcefile)); Create a new file output stream and buffer it outbuff=new bufferedoutputstream (new FileOutputStream (targetfile)); Buffer arra
Java 8 enhanced tool class Arrays notes, java8arrays
Make notes at willArrays tool categories are divided into two categories: Single-thread and multi-threadAll of the following statements with a subscript range are headers without tails.Single thread:1. binarySearch: The subscript of the key in the search array: binar
1. How do I get rid of marshaller formatting?:
Jaxbcontext context = Jaxbcontext.newinstance (Entity. Class);
Marshaller Marshaller = Context.createmarshaller ();
//XML format
Marshaller.setproperty (Marshaller.jaxb_formatted_output, true);
//Remove the default headers that generate XML
Marshaller.setproperty (Marshaller.jaxb_fragment, true);
//non-escape character handling
Marshaller.setproperty (Characterescapehandler. Class.ge
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.