java 缩略图 实现
import java.awt.image. * ;
import com.sun.image.codec.jpeg. * ;
public class poiReadDoc {
Image img = null;
int width = 0,height =0;
String destFile = "";
public void readImg(String fileName) throws IOException{
File _file = new File(fileName); // 读入文件
// String srcFile = _file.getName();
destFile = fileName.substring( 0 , fileName.lastIndexOf(".")) + " _mini.jpg " ;
img = javax.imageio.ImageIO.read(_file); // 构造Image对象
width = img.getWidth( null ); // 得到源图宽
height = img.getHeight( null ); // 得到源图长
}
public void resize( int w, int h) throws IOException {
BufferedImage _image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
_image.getGraphics().drawImage(img, 0 , 0 , w, h, null ); // 绘制缩小后的图
FileOutputStream out = new FileOutputStream(destFile); // 输出到文件流
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(_image); // 近JPEG编码
out.close();
}
public void resize( double t) throws IOException {
int w = ( int ) (width * t);
int h = ( int ) (height * t);
resize(w, h);
}
public&n
相关文档:
1. HttpSession session = request.getSession()
与HttpSession session = request.getSession(true)的区别?
参考答案:
getSession(true)的函数原型为::HttpSession session = request.getSession (Boolean create)
如果有与当前的request先关联的HttpSession,那么返回request相关联的HttpS ......
先贴一段
Java
基本结构
Java
结构包括四个不同而又相关的部分:
Java
语言、
class
文件格式、应用程序接
口、虚拟机
其中,虚拟机的主要任务是在程序运行中需要的时候调用
class
文件并执行其中的字节码。一个
Java
应
用有两种
class loader
:
the system class loader
和
class loader objects
......
1、Oracle8/8i/9i数据库(thin模式)
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl"; //orcl为数据库的SID
String user="test";
String password="test";
Connection conn= DriverManager.getConnection(url,user,password);
2、DB ......
/*
Function name: myGetHttpFile2
Description: 爬网页用
Input: URL 例如:http://www.126.com
Output: 字符串,网页的HTML
*/
public String myGetHttpFile2(String url){
String authentication=null;
ArrayList al=new ArrayList();
String PageURL = url;
......