Java数字转字符串前面自动补0的实现
本文原址:http://blogger.org.cn/blog/more.asp?name=hongrui&id=46926
/**
* Java里数字转字符串前面自动补0的实现。
*
*/
public class TestStringFormat {
public static void main(String[] args) {
int youNumber = 19;
// 0 代表前面补充0
// 4 代表长度为4
// d 代表参数为正数型
String str = String.format("%02d", youNumber);
System.out.println(str); // 01
}
}
相关文档:
Java NIO API详解
在JDK
1.4以前,Java的IO操作集中在java.io这个包中,是基于流的阻塞(blocking)API。对于大多数应用来说,这样的API使用很方
便,然而,一些对性能要求较高的应用,尤其是服务端应用,往往需要一个更为有效的方式来处理IO。从JDK 1.4起,NIO
API作为一个基于缓冲区,并能提供非阻塞(non-blo ......
JAVA的设计原则
1. 接口隔离原则(ISP:Interface Segregation Principle)
定义:使用多个专门的比使用单一的总接口要好。也可以说:建立单一接口,不要建立臃肿庞大的接口。
ISP的两种定义:
◇ “Clients should not be forced to depend upon interfaces that they don't u ......
from Rxtx
This page is for general content regarding the use of rxtx. Feel free to add your own content.
Using RXTX In Eclipse
Deploying JAVA with RXTX
I wrote an app several months ago using javax.comm on windows. Sun has left me high and dry. rxtx help!
download ftp://ftp.qbang.org/pub/rx ......
这篇文章和SUN公司提供的教程类似,中间多了一个HelloImpl的java文件,编译时的命令也就有所不同了
原来的命令为:Server javac HelloServer.java HelloApp/*.java
......
/*
* EncryptUtils.java
* Copyright (C) 2007-3-19 <JustinLei@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* ......