1. Create a table:
Copy Code code as follows:
drop table if exists photo;
CREATE TABLE Photo (
ID INT not NULL auto_increment PRIMARY KEY,
Name VARCHAR (m) COMMENT ' names ',
Photo blob COMMENT ' photo '
)
Engine=innodb
DEFAULT Charset=utf8
Collate=utf8_general_ci;
The data stored in the MySQL format is a blob type; A blob is a container in which binary files can be stored.
2. Write the image stream data Access Tool class:
Copy Code code as follows:
Recently, due to work requirements, a tool class for Excel operations is based on poi. Share with you.
Package COM. shine. framework. core. office; import Java. io. fileinputstream; import Java. io. filenotfoundexception; import Java. io. fileoutputstream; import Java. io.
1.Java Serialization and deserialization
Java serialization refers to the process of converting a Java object into a sequence of bytes, while Java deserialization refers to the process of restoring a byte sequence to a Java object.
2. Why serialization and deserialization
The map collection can hold key-value mapping relationships, this is very suitable for this example of the data structure required, all the province information can be saved as a key to the map collection, and each key can save the corresponding city information, this example is the use of map collection to achieve the provincial and municipal cascade selection box, when the province information selection,
voidMain (string[] args) {File file=NewFile ("D:" + file.separator + "Yi.txt");//specify the file to write toOutputStream out=NULL;//define a byte stream output object Try{ out=NewFileOutputStream (file);//gets the actual byte stream output object, covering the contents of the}Catch(FileNotFoundException e) {e.printstacktrace (); } String Info= "Hello";//What to enter byte[] b=info.getbytes ();//Convert a character to a byte array Try{out.write (b); } Catch(IOException e) {
Learn Java friends should know that Java from the beginning of the platform to play a non-independent banner, said "write once, run everywhere", actually speaking of irrelevant, the Java platform has another irrelevant that is language-independent, to achieve the language of independence, Then the Java System class fil
performance of Java applications. In my experience, the file change notifier in Nio.2 is one of the most interesting (underrated) features of the new input/output API.
Many enterprise applications need to do some special processing in the following situations:
When a file is uploaded to an FTP folderWhen the definition in a configuration is modifiedWhen a draft document is uploadedWhen other file system events occurThese are examples of change noti
Java RMI distributed program development example
Author: javaboy2012Email: yanek@163.comQQ: 1046011462
I. Server Side
Interface Definition: note that the remote interface must be inherited.
Package com. Yanek. RMI. server;
Import java. RMI. Remote;Import java. RMI. RemoteException;Import
/** Function Description: reads the value corresponding to a key of the resource file.* @ Param key refers to the corresponding key in the resource file; for example, com.cn. Test* @ Param file_path: the path of the resource file, which can be an absolute path. For example,/test. properties.*/Private Static string readproperties (string key, string file_path ){Properties props = new properties ();
Inputstre
Introduction:
About Java IO flow is very common, basically every project will be used, each encounter is to find a search on the internet, and tried. Last time a colleague asked me to read a Java file, I suddenly Meng the first reaction is to go online to find, although also can find, but their total feeling is not very practical, so today took time to see some of the
. Test"); // Generate an instance$ Test-> setName ("haha, PHP calls the JAVA method! "); // The subsequent call is the same as the class method called in php. Echo "call the getName method of the Test class. The returned value is:". $ test-> getName (). "Echo "call the add Method of Test and return value:". $ test-> add (11.2, 15.7 );?> Browser call output:Call the getName method of the Te
the name of the method, and Java to the identifier is a certain specification, is not a specification, that can be observed can not be followed, but the recommendation is best to abide by , after all, this is the accumulated experience of many years of programming. The naming conventions for their identifiers include the following:The first character of an identifier must be a letter, an underscore "_", a dollar sign "$";Identifiers are made up of nu
Example 1, using lambda expression to implement runnableWhen I started using Java 8 o'clock, the first thing I did was to replace the anonymous class with a lambda expression, and the implementation of the Runnable interface was the best example of an anonymous class. Take a look at the runnable implementation before Java
Java thread pool example
When we are doing a lot of highly concurrent applications, the bottleneck of a single thread cannot meet our needs. At this time, it is a conventional solution to use multithreading to increase the processing speed. When multithreading is used, we can use the thread pool to manage our threads. The advantages of using the thread pool are not mentioned.
This is also very important for
The Apache POI is an open source library of the Apache Software Foundation, and POI provides the ability for the API to read and write to Microsoft Office format files in Java programs.
1. Read the jar packs that Word 2003 and Word 2007 need
A Word file that reads Version 2003 (. doc) is relatively simple, requiring only Poi-3.5-beta6-20090622.jar and Poi-scratchpad-3.5-beta6-20090622.jar two jar packages, and 2007 version (. docx) on more trouble,
upload file directory.
Do the file upload and download the specific operation:
First, load the necessary jar packs: "Commons-fileupload-1.2.1.jar", "Commons-io-1.4.jar"
Steps:
0. Create the object of the Fileitemfactory subclass Diskfileitemfactory
1. In order to get the Servletfileupload object, first you need to get an object of fileitemfactory, and then call new Servletfileupload (Fileitemfactory fif); method to get the Servletfileupload object
2. In order to get a set of Fileitem, we
These days, has been in the Java "memory leak" problem entangled. The memory consumed by Java applications continues to rise regularly, exceeding the monitoring threshold. Sherlock Holmes had to take a shot.
Memory overflow out of memory, which means that the program does not have enough memory space for it to use when applying for memory, and it appears out of the memory; For
ThreadLocal in Java is another-achieve thread-safety apart from writing immutable classes. If you had been writing multi-threaded or concurrent code in Java then you must being familiar with cost of synchronization or locking which can greatly affect Scalability of application, but there was no choice other than synchronize if you are S Haring objects between multiple threads. ThreadLocal in
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.