¼òµ¥µÄjavaͼƬËõ·Å´úÂë
/**
* @param source: source image file
* @param output: output image file
* @param mode: 0 ratio,1 maxWidth,2 maxHeight,3 maxSide
* @param maxSide: maxWidth, maxHeight or maxSide, different by mode
* @param ratio: ratio if resized by ratio
*/
public static void resizeImage(File source, File output, int mode, Integer maxSide, Double ratio)
throws IOException {
// read image
Image sourceImage = ImageIO.read(source);
// resize image
BufferedImage outputImage = getResizeImage(sourceImage, mode, maxSide, ratio);
// wirite image to file
wirteImageToFile(outputImage, output);
}
/**
* @param source: source image
* @param mode: 0 ratio,1 maxWidth,2 maxHeight,3 maxSide
* @param maxSide: maxWidth, maxHeight or maxSide, different by mode
* @param ratio: ratio if resized by ratio
*/
public static BufferedImage getResizeImage(Image source, int mode, Integer maxSide, Double ratio) {
int srcImageWidth = source.getWidth(null);
int srcImageHeight = source.getHeight(null);
int width = 0, height = 0;
switch (mode) {
case 0:
// resize by ratio
width = (int) (srcImageWidth * ratio);
height = (int) (srcImageHeight * ratio);
break;
case 1:
// resize by max width
width = maxSide;
height = new BigDecimal(srcImageHeight).divide(new BigDecimal(srcImageWidth), 5, RoundingMode.HALF_EVEN)
.multiply(new BigDecimal(width)).intValue();
break;
case 2:
// resize by max height
height = maxSide;
width = new BigDecimal(srcImageWidth).divide(new BigDecimal(srcImageHeight), 5, RoundingMode.HALF_EVEN)
.multiply(new BigDecimal(height)).intValue();
break;
case 3:
// resize by max side(between width and height)
if (srcImageWidth > srcImageHeight) {
width = maxSide;
height = maxSide * srcImageHeight / srcImageWidth;
} else {
width = maxSide * srcImageWidth / srcImageHeight;
height = maxSide;
}
break;
}
BufferedImage t
Ïà¹ØÎĵµ£º
import java.io.*;
public class FileReaderSample {
public static void main(String args[]) throws IOException
{
// ½¨Á¢¿ÉÈÝÄÉ1024¸ö×Ö·ûµÄÊý×é
char data[]=new char[1024];
// ½¨Á¢¶ÔÏófr
FileReader fr= ......
´¦ÀíÂÒÂëÎÊÌâ
1¡¢¹æ·¶Êý¾Ý¿âºÍÒ³ÃæËùÓбàÂëͳһΪһÖÖÀýÈçutf-8
2¡¢hibernateÁ¬½ÓÊý¾Ý¿âÉèÖÃÁ¬½Ó±àÂë
<session-factory>
<property name="connection.url">
jdbc:mysql://127.0.0.1:3306/leaveword?useUnicode=true&characterEncoding=utf-8
& ......
#dd_traces.pl (C) Marko Kivij?rvi 2006
# Dummy checks
die "Specify an input file!\n" if $ARGV[0] eq "";
die "File not found!\n" unless -e $ARGV[0];
die "Incorrect file extension for a C/C++ file!\n"
if ( $ARGV[0] !~ /(.*)\.(java)$/ );
# Constants
my $IMPORT_LOG_PACKAG = "\n ......
http://liuleijsjx.javaeye.com/blog/422343
±¾È˸ÕдµÄѧϰÐĵà ϣÍûÄÜÓÐËù°ïÖú
/**
*´úÂëʵÀý ͨ¹ý·´±àÒë²é¿´keytoolµÄjava code»ñµÃµÄÊý×ÖÖ¤ÊéµÄÄÚ²¿Éú³É·½·¨
*ÍÆ¼öʹÓÃjdk1.5
**/
1¡£Ê×ÏÈÉú³Éselfcert
CertAndKeyGen cak = new CertAndKeyGen("RSA","MD5WithRSA",null);
//²ÎÊý·Ö±ðΪ ¹«Ô¿ ......
¶ÔÓÚObjectÀà,ËüÌṩÁËÒ»¸ö×î×îÑÏÃܵÄʵÏÖ,ÄǾÍÊÇÖ»ÓÐÊÇͬһ¶ÔÏóʱ,equals·½·¨²Å·µ»Øtrue,Ò²¾ÍÊÇÈËÃdz£ËµµÄÒýÓñȽ϶ø²»ÊÇÖµ±È½Ï.Õâ¸öʵÏÖÑÏÃܵÃÒѾûÓÐʲôʵ¼ÊµÄÒâÒå, ËùÒÔÔÚ¾ßÌå×ÓÀà(Ïà¶ÔÓÚObjectÀ´Ëµ)ÖÐ,Èç¹ûÎÒÃÇÒª½øÐжÔÏóµÄÖµ±È½Ï,¾Í±ØÐëʵÏÖ×Ô¼ºµÄequals·½·¨
equals ·½·¨ÊÇ java.lang.Object ÀàµÄ·½·¨¡£
ÓÐÁ½ÖÖÓ ......