下面產(chǎn)生一個(gè)自簽證書。安裝完J2SDK(這里用的是J2SDK1.4)后,在J2SDK安裝目錄的bin目錄下,有一個(gè)keytool的可執(zhí)行程序。利用keytool產(chǎn)生自簽證書的步驟如下:
10年的潛江網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。營銷型網(wǎng)站的優(yōu)勢是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整潛江建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)從事“潛江網(wǎng)站設(shè)計(jì)”,“潛江網(wǎng)站推廣”以來,每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。
第一步,用-genkey命令選項(xiàng),產(chǎn)生公私密鑰對(duì)。在控制臺(tái)界面輸入:keytool -genkey -alias testkeypair -keyalg RSA -keysize 1024 -sigalg MD5withRSA。這里的-alias表示使用這對(duì)公私密鑰產(chǎn)生新的keystore入口的別名(keystore是用來存放管理密鑰對(duì)和證書鏈的,缺省位置是在使用者主目錄下,以.keystore為名的隱藏文件,當(dāng)然也可指定某個(gè)路徑存放.keystore文件);-keyalg是產(chǎn)生公私鑰對(duì)所用的敏橘罩算法,這里是RSA;-keysize定義密鑰的長度;-sigalg是簽伍饑名橋鬧算法,選擇MD5withRSA,即用RSA簽名,然后用MD5哈希算法摘要。接下來,系統(tǒng)會(huì)提示進(jìn)行一些輸入:
輸入keystore密碼: abc123
您的名字與姓氏是什么?
[Unknown]: Li
您的組織單位名稱是什么?
nbs
問題的其他解決辦法參考 :
;t=JAVA+
public BufferedImage replaceWithWhiteColor(BufferedImage bi) {
int[] rgb = new int[3];
int width = bi.getWidth();
int height = bi.getHeight();
int minx = bi.getMinX();
int miny = bi.getMinY();
/**
* 遍歷圖片的像素,為處理圖片上的雜色,所以要把指襲如雀定像素上的顏色換成目標(biāo)白色 用二層循環(huán)遍歷長和寬上的每個(gè)像素
*/
int hitCount = 0;
for (int i = minx; i width-1; i++) {
for (int j = miny; j height; j++) {
/**
* 得到指定像素(i,j)上的RGB值,
*/
int pixel = bi.getRGB(i, j);
int pixelNext = bi.getRGB(i+1, j);
/**
* 分別進(jìn)行位操作得到 r g b上的值橡乎
*/
rgb[0] = (pixel 0xff0000) 16;
rgb[1] = (pixel 0xff00) 8;
rgb[2] = (pixel 0xff);
/**
* 進(jìn)行換色操作,我這里是要換成白底,那么就判斷圖片中rgb值是否在范圍內(nèi)的像素
*/
//經(jīng)過不斷嘗試,RGB數(shù)值相互間相差15以內(nèi)的都基本上是灰色,
//對(duì)以身份證來說特別是介于73到78之間,還有大于100的部分RGB值都是干擾色,將它們一次拍早性轉(zhuǎn)變成白色
if ((Math.abs(rgb[0] - rgb[1]) 15)
(Math.abs(rgb[0] - rgb[2]) 15)
(Math.abs(rgb[1] - rgb[2]) 15)
(((rgb[0] 73) (rgb[0] 78))||(rgb[0] 100))) {
//進(jìn)行換色操作,0xffffff是白色
bi.setRGB(i, j, 0xffffff);
}
}
}
我當(dāng)初用struts1和hibernate做了個(gè)簡單的!主要的邏輯代碼在下面!數(shù)據(jù)庫里號(hào)碼對(duì)應(yīng)的城市在網(wǎng)上可念局以查的到
package dao;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.criterion.Expression;
import entity.Shenfenzhen;
public class IdDao {
private static Configuration configuration = new Configuration().configure() ;
private static SessionFactory sessionFactory =configuration.buildSessionFactory();
private static Session session = null;
public Info query(String s){
Info info = null;
StringBuffer stringBuffer = new StringBuffer(s);
if(s.length()==18){
String end = stringBuffer.substring(17);
//System.out.println(end);
if(!end.matches("\\d||x")){
return null;
}
}
else if(s.length()==15){
stringBuffer.insert(6, "19");
stringBuffer.append("3");
}
int i = Integer.parseInt(stringBuffer.substring(0, 6));
//System.out.println(i);
session = sessionFactory.openSession();
Criteria criteria = session.createCriteria(Shenfenzhen.class);
criteria.add(Expression.eq("num", i));
ListShenfenzhen list = criteria.list();
String address = null;
try {
address = list.get(0).getAddress();
}catch (Exception e) {
return null;
}
i = Integer.parseInt(stringBuffer.substring(16,17));
String sex = null;
if(i%2==0){
sex = "女";
}else{
sex = "男";
}
//System.out.println(i);
stringBuffer = new StringBuffer(stringBuffer.substring(6, 14));
// stringBuffer.insert(4, "-");
// stringBuffer.insert(7, "-"凱納);
//System.out.println(stringBuffer);
String ss = stringBuffer.toString();
SimpleDateFormat dateFormat = new SimpleDateFormat("仔孫讓yyyyMMdd");
String brithday="";
int year=0;
int month =0;
int day =0;
try {
Date date = dateFormat.parse(ss);
//System.out.println(date);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
year = calendar.get(Calendar.YEAR);
month = calendar.get(Calendar.MONTH)+1;
day = calendar.get(Calendar.DAY_OF_MONTH);
brithday = (String)(year + "年" + month + "月" + day + "日");
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
info = new Info(address, brithday, sex);
Calendar c = Calendar.getInstance();
int nowYear = c.get(Calendar.YEAR);
int nowMonth = c.get(Calendar.MONTH);
int nowDay = c.get(Calendar.DAY_OF_MONTH);
if(nowYearyear){
info = null;
}else if(nowYear ==year nowMonthmonth ){
info = null;
}else if(nowYear == year nowMonth==month nowDayday){
info = null;
}
closeSession(session);
return info;
}
// public static void main(String[] args){
// IdDao dao = new IdDao();
// dao.query("342522998711224513");
// System.out.println("x".matches("\\d||x"));
// }
private void closeSession(Session session){
if(session !=null){
session.close();
}
}
}
首蠢信先 來看看效果 如下圖
帶激輪
代碼如下
PrintTest java
import java awt BasicStroke;
鉛穗import java awt Color;
import java awt Font;
import java awt Graphics;
import java awt Graphics D;
import java awt print Book;
import java awt print PageFormat;
import java awt print Paper;
import java awt print Printable;
import java awt print PrinterException;
import java awt print PrinterJob;
import java text SimpleDateFormat;
import java util Date;
import snjp model RentDetail;
import snjp parameter RentRecordParameter;
public class PrintTest implements Printable
{
private String roomID;
private Date printDate;
private Integer rentType;
private Float waterFee;
private Float electricityFee;
private Float rent;
private String remark;
private static int RECEIPT_NO = ;
public PrintTest()
{
}
public PrintTest printTest;
public PrintTest(RentRecordParameter prentRecord RentDetail prentDetail)
{
this roomID = prentRecord getRoomId()+ 房間 ;
this printDate = prentRecord getRegisterDate();
this rentType = prentRecord getRentType();
this waterFee = prentDetail getWaterBill();
this electricityFee = prentDetail getElectricityBill();
this rent = prentDetail getRent();
this remark = prentDetail getRemark();
}
/** */
/**
* @param Graphic指明打印的圖形環(huán)境
* @param PageFormat指明打印頁格式(頁面大小以點(diǎn)為計(jì)量單位 點(diǎn)為 英才的 / 英寸為 毫米 A 紙大致為 × 點(diǎn))
* @param pageIndex指明頁號(hào)
**/
public int print(Graphics graphics PageFormat pf int pageIndex)
throws PrinterException
{
//print string
String receiptTitle = 收款收據(jù) ;
String content = 今收到 ;
String feeItem = null;
Float rentTotal = f;
String content = 總計(jì)人民幣(大寫) ;
//收款的內(nèi)容(根據(jù)租賃類型 只有 房租 房租 水費(fèi) 電費(fèi) 兩種值)
switch(this rentType)
{
case :
feeItem = 房租 押金 ;
rentTotal=this rent;
break;
case :
feeItem = 房租 押金 水費(fèi) 電費(fèi) ;
rentTotal=this rent+this electricityFee+this waterFee;
break;
default:
feeItem = 未知收費(fèi)項(xiàng)目 ;
}
//轉(zhuǎn)換成Graphics D
Graphics D graphics D = (Graphics D) graphics;
//設(shè)置打印顏色為黑色
graphics D setColor(Color black);
//打印起點(diǎn)坐標(biāo)x=
double x = pf getImageableX();
double y = pf getImageableY();
System out println( 打印起點(diǎn)坐標(biāo)值是{ +x+ +y+ } );
switch (pageIndex)
{
case :
//設(shè)置打印字體(字體名稱 樣式和點(diǎn)大?。ㄗ煮w名稱可以是物理或者邏輯名稱)
//Java平臺(tái)所定義的五種字體系列 Serif SansSerif Monospaced Dialog 和 DialogInput
Font font = new Font( 新宋體 Font TRUETYPE_FONT );
graphics D setFont(font);//設(shè)置字體
BasicStroke?? basicStroke=new?? BasicStroke( f);
float[] dash = { f };
//設(shè)置打印線的屬性
// 線寬; ; ; 空白的寬度; 虛線的寬度; 偏移量
//??????????????? graphics D setStroke(new BasicStroke( f
//??????????????????????????????? BasicStroke CAP_BUTT BasicStroke JOIN_MITER
//??????????????????????????????? f dash f));
//graphics D setStroke(new BasicStroke( f));
graphics D setStroke(basicStroke);//設(shè)置線寬
float height = font getSize D();//字體高度
System out println( 字體高度是 +height);
//繪制收據(jù)標(biāo)題
graphics D drawString(receiptTitle (float) y + * height);
//繪制收據(jù)編號(hào)
String receiptNo = String valueOf(RECEIPT_NO);
graphics D drawString( No : +GlobalMethod get String(receiptNo ) (float)x* (float) y + * height);
//繪制打印時(shí)間
SimpleDateFormat myDateFormat = new SimpleDateFormat( yyyy年MM月dd日 );
graphics D drawString(myDateFormat format(printDate) (float)x* (float) y + * height);
//繪制收據(jù)標(biāo)題下面的第一條橫線
graphics D drawLine(
(int) (y + * height+ )
(int) (y + * height+ )
);
//繪制收據(jù)標(biāo)題下面的第二條橫線
graphics D drawLine(
(int) (y + * height+ )
(int) (y + * height+ )
);
//正文 ——今收到
graphics D drawString(content (float) x* (float) y + * height);
//收費(fèi)項(xiàng)目名稱
graphics D drawString(this roomID+feeItem (float) x* (float) y + * height);
//繪制正文 下劃線
graphics D drawLine(
(int)x*
(int) (y + * height+ )
(int)x+
(int) (y + * height+ )
);
//人民幣(大寫)
graphics D drawString(content +Money NumToRMBStr(rentTotal) (float) x* (float) y + * height);
//繪制人民幣(大寫)下劃線
graphics D drawLine(
(int)x*
(int) (y + * height+ )
(int)x+
(int) (y + * height+ )
);
//(小寫)
graphics D drawString( (小寫) +rentTotal+ 元 (float) x* (float) y + * height);
//繪制(小寫)下劃線
graphics D drawLine(
(int)x*
(int) (y + * height+ )
(int)x+
(int) (y + * height+ )
);
//附注
graphics D drawString( 附注: +this remark (float) x* (float) y + * height);
//繪制附注下劃線
graphics D drawLine(
(int)x* +
(int) (y + * height+ )
(int)x+
(int) (y + * height+ )
);
// 簽字(收款人)
graphics D drawString( 簽字(收款人) (float) x* + (float) y + * height);
//簽字(收款人)下劃線
graphics D drawLine(
(int)x*
(int) (y + * height+ )
(int)x+
(int) (y + * height+ )
);
return PAGE_EXISTS;
default:
RECEIPT_NO=RECEIPT_NO ;
return NO_SUCH_PAGE;
}
}
//方法調(diào)用
public? void printReceipt(PrintTest printTest){
//通俗理解就是書 文檔
Book book = new Book();
//設(shè)置成豎打
PageFormat pf = new PageFormat();
pf setOrientation(PageFormat PORTRAIT);
//通過Paper設(shè)置頁面的空白邊距和可打印區(qū)域 必須與實(shí)際打印紙張大小相符
Paper p = new Paper();
p setSize( );//紙張大小
p setImageableArea( );//A ( X )設(shè)置打印區(qū)域 其實(shí) 應(yīng)該是 因?yàn)锳 紙的默認(rèn)X Y邊距是
pf setPaper(p);
//把 PageFormat 和 Printable 添加到書中 組成一個(gè)頁面
book append(printTest pf);
//獲取打印服務(wù)對(duì)象
PrinterJob job = PrinterJob getPrinterJob();
//設(shè)置打印類
job setPageable(book);
try
{
//可以用printDialog顯示打印對(duì)話框 在用戶確認(rèn)后打印 也可以直接打印
//??????????? boolean isShowing=job printDialog();
//??????????? if(isShowing)
//??????????? {
//????????????? System out println(this printDate+ ************* );
RECEIPT_NO=RECEIPT_NO+ ;
job print();
//??????????? }
}
catch (PrinterException e)
{
e printStackTrace();
}
}
public static void main(String[] args)
{
//??? 通俗理解就是書 文檔
Book book = new Book();
//??? 設(shè)置成豎打
PageFormat pf = new PageFormat();
pf setOrientation(PageFormat PORTRAIT);
//??? 通過Paper設(shè)置頁面的空白邊距和可打印區(qū)域 必須與實(shí)際打印紙張大小相符
Paper p = new Paper();
p setSize( );//紙張大小
p setImageableArea( );//A ( X )設(shè)置打印區(qū)域 其實(shí) 應(yīng)該是 因?yàn)锳 紙的默認(rèn)X Y邊距是
pf setPaper(p);
//??? 把 PageFormat 和 Printable 添加到書中 組成一個(gè)頁面
book append(new PrintTest() pf);
//獲取打印服務(wù)對(duì)象
PrinterJob job = PrinterJob getPrinterJob();
// 設(shè)置打印類
job setPageable(book);
try
{
//可以用printDialog顯示打印對(duì)話框 在用戶確認(rèn)后打印 也可以直接打印
//boolean a=job printDialog();
//if(a)
//{
job print();
//}
}
catch (PrinterException e)
{
e printStackTrace();
}
}
lishixinzhi/Article/program/Java/hx/201311/25778