
java
文章平均质量分 63
gmemai
这个作者很懒,什么都没留下…
展开
-
java 四舍五入保留小数
// 方式一:double f = 3.1516;BigDecimal b = new BigDecimal(f);double f1 = b.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();// 方式二:new java.text.DecimalFormat("#.00").format(3.1415926);// #.00 表示两位小数 #转载 2015-08-31 17:30:21 · 471 阅读 · 0 评论 -
RMI与RPC
分布式对象(Distributed Objects) 架构实例有CORBA/RMI/DCOM/.NET Remoting 远程过程调用(Remote Procedure Call) 架构实例有SOAP/XML-RPC/Flash AMF转载 2015-10-10 10:24:10 · 334 阅读 · 0 评论 -
Random Access Files
Random access files permit nonsequential, or random, access to a file’s contents. To access a file randomly, you open the file, seek a particular location, and read from or write to that file.This func转载 2015-10-09 13:33:50 · 446 阅读 · 0 评论 -
How to Change the MySQL Timeout on a Server
A MySQL server timeout can occur for many reasons, but happens most often when a command is sent to MySQL over a closed connection. The connection could have been closed by the MySQL server because of转载 2015-10-16 13:52:22 · 658 阅读 · 0 评论 -
Java Non-Blocking and Asynchronous IO with NIO & NIO.2 (JSR203) - Reactor/Proactor Implementations
Proactor/Reactor asynchronous IO patterns. I can see how by using selectable channels I can implement a Reactor style asynchronous IO mechanism quite easy (and have done so). But, I cannot see how I wo转载 2015-10-17 12:21:32 · 675 阅读 · 0 评论 -
Java MongoDB : Save image example
In this tutorial, we show you how to use collection.remove() to delete documents from the collection.1. Test DataInsert 10 documents from number 1 to 10 for testing.for (int i=1; i <= 10; i++) { co转载 2015-09-29 22:19:04 · 415 阅读 · 0 评论 -
iBATIS - Hibernate
There are major differences between iBATIS and Hibernate. Both the solutions work well, given their specific domain. iBATIS is suggested in case −You want to create your own SQL’s and you are willing转载 2015-10-16 13:43:18 · 446 阅读 · 0 评论 -
MYSQL 8 Hours Time out Problem
I am using MYSQL 5.0 and Tomcat 5.5. After 8 hours , MYSQL closes by default all idle connections and so I am getting an SQL Exception .Any solution to this problemWhich connection pool are you using?转载 2015-10-16 13:17:18 · 710 阅读 · 0 评论 -
Java MongoDB : Update document
In this tutorial, we show you how to use Java MongoDB API collection.update() to update documents.Test DataAssume following data/documents are inserted.{ "hosting" : "hostA", "type" : "vps",转载 2015-09-29 07:36:47 · 819 阅读 · 0 评论 -
Java – How to delay few seconds
In Java, you can use Thread.sleep(miliseconds) to make the current executing Java program to sleep or delay few seconds.TestSleep.javapackage com.mkyong.test;import java.util.Date;public class TestSlee转载 2015-09-29 09:33:11 · 362 阅读 · 0 评论 -
What is the difference between a soft reference and a weak reference in Java?
Weak referencesA weak reference, simply put, is a reference that isn’t strong enough to force an object to remain in memory. Weak references allow you to leverage the garbage collector’s ability to det转载 2015-09-28 15:12:23 · 376 阅读 · 0 评论 -
A guide to object cloning in java
A clone is an exact copy of the original. In java, it essentially means the ability to create an object with similar state as the original object. The clone() method provides this functionality. In thi转载 2015-09-28 14:14:11 · 362 阅读 · 0 评论 -
Java中getResourceAsStream的用法
代码中读取一些资源文件(txt,gif等等),单独运行的时候,没问题,但是将项目打jar后,尽管资源文件在jar包内,但我们却怎么也访问不到它了。src|---com ---cn ---ChineseUtil.java src|---pinyin.txt ChineseUtil.java package com转载 2015-09-10 17:24:37 · 457 阅读 · 0 评论 -
ClassLoader.getResourceAsStream() 与 Class.getResourceAsStream()的区别
Class.getResourceAsStream()会指定要加载的资源路径与当前类所在包的路径一致。 例如你写了一个MyTest类在包com.test.mycode下,那么MyTest.class.getResourceAsStream("name") 会在com.test.mycode包下查找相应的资源。 如果这个name是以 ‘/’ 开头的,那么就会从classpath的根路径下开始查找。转载 2015-09-10 17:07:35 · 304 阅读 · 0 评论 -
关于ArrayList的5道面试题
1、ArrayList的大小是如何自动增加的?在ArrayList中增加一个对象的时候,Java会去检查ArrayList,以确保已存在的数组中有足够的容量来存储这个新的对象。如果没有足够的容量,那么就会新建一个长度更长的数组,旧的数组会被使用Arrays.copyOf方法被复制到新的数组中去,现有的数组引用指向了新的数组。//ArrayList Add方法:public boolean add(翻译 2015-09-25 14:20:51 · 399 阅读 · 0 评论 -
Java NIO 2.0 : Memory-Mapped Files | MappedByteBuffer Tutorial
If you know how java IO works at lower level, then you will be aware of buffer handling, memory paging and other such concepts. For conventional file I/O, in which user processes issue read() and write转载 2015-10-15 11:20:11 · 569 阅读 · 0 评论