ITeye博客

Java

共 14 篇文章

Apache Camel: Integration Nirvana

Apache Camel: Integration Nirvana 原文地址:https://dzone.com/articles/apache-camel-integration Take any integration project and you have multiple applications talking over multiple transports on multiple platforms. As you can imagine, in large enterprise applications this can get complex very fast. Muc…

2015-10-14 09:49 · Java · Apche Camel

适配器模式Adapter

适配器模式有2种 第一种是“ 面向类的适配器模式 ”, 第二种是“ 面向对象的适配器模式 ”。 先说“面向类的适配器模式”。顾名思义,这类适配器模式就是主要用于,单一的为某个类而实现适配的这样一种模式,为什么说只为某个类去实现,一会提到,我们先展示这种类适配模式的代码实现。 源的代码如下: public class Person { private String name; private String sex; private int age; public void speakJapanese(){ System.out.println("I can speak Japanese!");…

2015-08-27 22:50 · Java · Design Pattern · 设计模式

使用SLF4J

每一个Java程序员都知道日志对于任何一个Java应用程序,尤其是服务端程序是至关重要的,而很多程序员也已经熟悉各种不同的日志库如java.util.logging、Apache log4j、logback。但如果你还不知道 SLF4J (Simple logging facade for Java)的话,那么是时候去在你项目中学习使用SLF4J了。 在这篇文章中,我们将学习为什么使用SLF4J比log4j或者java.util.logging要优秀。 不管怎样,让我们回到这个话题,SLF4J不同于其他日志类库,与其它有很大的不同。SLF4J(Simple logging Facade fo…

2015-08-27 21:14 · Java · Log

[转]Java Socket实战之四 传输压缩对象

上一篇文章说到了用Java Socket来传输对象,但是在有些情况下比如网络环境不好或者对象比较大的情况下需要把数据对象进行压缩然后在传输,此时就需要压缩这些对象流,此时就可以GZIPInputStream和GZIPOutputStream来处理一下socket的InputStream和OutputStream。 仍然需要一个实现了java.io.Serializable接口的简单Java对象 package com.googlecode.garbagecan.test.socket.sample4; public class User implements java.io.Serializ…

2015-08-18 23:29 · Java · Socket · NIO

XML认证教程,第 8 部分: SAX Parser [转]

http://www.ibm.com/developerworks/cn/xml/x-cert/part8/index.html 简介: 读取和操纵 XML 文件的标准方法是 DOM(“文档对象模型”)。遗憾的是,这种方法需要读取整个文件并将它存储到树结构中,因而效率不高、缓慢,并且会过度使用资源。 什么是 SAX 读取和操纵 XML 文件的标准方法是 DOM(“文档对象模型”)。遗憾的是,这种方法需要读取整个文件并将它存储到树结构中,因而效率不高、缓慢,并且会过度使用资源。 一种替代方法是使用 Simple API for XML 或 SAX。SAX 允许正在读取文档时处理该文档,这避免了…

2013-03-14 15:47 · Java · XML

XML and Java - Parsing XML using Java Tutorial [转]

http://www.java-samples.com/showtutorial.php?tutorialid=152 Parsing XML If you are a beginner to XML using Java then this is the perfect sample to parse a XML file create Java Objects and manipulate them. The idea here is to parse the employees.xml file with content as below <?xml version="1.0" enc…

2013-03-14 15:40 · Java · XML

java 动态代理深度学习[转]

一.相关类及其方法: java.lang.reflect.Proxy, Proxy 提供用于创建动态代理类和实例的静态方法. newProxyInstance() 返回一个指定接口的代理类实例,该接口可以将方法调用指派到指定的调用处理程序 (详见api文档) java.lang.reflect.InvocationHandler, InvocationHandler 是代理实例的调用处理程序 实现的接口。 invoke() 在代理实例上处理方法调用并返回结果。在与方法关联的代理实例上调用方法时,将在调用处理程序上调用此方法。 (详见api文档) 二.源代码: 被代理对象的接口及实现类: pa…

2013-02-01 01:27 · Java

深入理解java多态性

(一)相关类 class A ...{ public String show(D obj)...{ return ("A and D"); } public String show(A obj)...{ return ("A and A"); } } class B extends A...{ public String show(B obj)...{ return ("B and B"); }

2012-07-04 12:36 · Java

Java debugging tutorial - 10 tips on debugging in java with example

Java debugging tutorial - 10 tips on debugging in java with example How to debug java program in Eclipse Debugging is a must have skill for any java developer. Having ability to debug java program enables to find you any subtle bug which is not visible during code review or comes when a particular …

2012-04-23 16:48 · Java · Eclipse

Top 30 Programming interview questions

Top 30 Programming interview questions Programming questions are integral part of any java or C++ programmer or software analyst interview. No matter on which language you have expertise it’s expected that you are familiar with fundamental of programming and can solve problems without taking help o…

2012-04-23 14:52 · Java

Top 20 Core Java Interview questions asked in Investment Bank

Top 20 Core Java Interview questions asked in Investment Bank This is a new series of sharing core Java interview question on Finance domain and mostly on Big Investment bank . Anybody who is preparing for any Java developer Interview on any Investment bank can be benefited from these set of core J…

2012-04-23 14:51 · Java

java 线程生命周期图

一图胜千言

2011-10-10 17:15 · Java

Java中BigDecimal的8种舍入模式

java.math.BigDecimal 不可变的、任意精度的有符号十进制数。BigDecimal 由任意精度的整数非标度值和32位的整数标度(scale)组成。 如果为零或正数,则标度是小数点后的位数。如果为负数,则将该数的非标度值乘以10的负scale次幂。 因此,BigDecimal表示的数值是(unscaledValue × 10-scale)。 与之相关的还有两个类: java.math.MathContext: 该对象是封装上下文设置的不可变对象,它描述数字运算符的某些规则,如数据的精度,舍入方式等。 java.math.RoundingMode: 这是一种枚举类型,定义了很多常…

2011-08-19 22:40 · Java

java.math.BigDecimal类的用法

在java中提供了大数字的操作类,即java.math.BinInteger类和java.math.BigDecimal类。这两个类用于高精度计 算,其中BigInteger类是针对大整数的处理类,而BigDecimal类则是针对大小数的处理类。下边我们介绍BigDecimal类: BigDecimal的实现利用到了BigInteger,不同的是BigDecimal加入了小数的概念。一般的float型和Double型数据只可 以用来做科学计算或者是工程计算,由于在商业计算中,要求的数字精度比较高,所以要用到java.math.BigDecimal类,它支持任何精度的定 点数,可以用它来精确计…

2011-08-19 22:33 · Java