java读取图片
Java code:
import java.awt.image.*;
import java.awt.*;
import java.io.*;
import javax.imageio.*;
public class ImageByte {
/**
* 转换Image数据为byte数组
*
* @param image
* Image对象
* @param format
* image格式字符串.如"jpeg","png"
* @return byte数组
*/
public static byte[] imageToBytes(BufferedImage image, String format) {
BufferedImage bImage = new BufferedImage(image.getWidth(null), image
.getHeight(null), BufferedImage.TYPE_INT_ARGB);
Graphics bg = bImage.getGraphics();
bg.drawImage(image, 0, 0, null);
bg.dispose();
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
ImageIO.write(bImage, format, out);
} catch (IOException e) {
e.printStackTrace();
// Log.log(null,"imageToBytes(): " e);
}
return out.toByteArray();
}
/**
* 转换byte数组为Image
*
* @param bytes
* Image的bytes数据数组
* @param filename
* 为要生成新的文件名
* @return boolean
*/
public static boolean ByteToImage(byte[] b, String filename) {
boolean bl = false;
File binaryFile = new File("e:\\test\\" + filename + ".
相关问答:
我的开发的平台是Myeclipes6.0 + tomcat5.x + mysql
我所有的编码方式都是用的UTF-8
我只用了Strtus框架
在一个form中如下用的是post的提交方式:
<form class="form" action=&quo ......
<%@page language="java" contentType="text/html;charset=gb2312" import="java.sql.*"%>
<jsp:useBean id="db" class="wang.connectDB"/>
< ......
目前有一个java程序,调用存储过程在数据库中写入一些数据,然后将这些数据传输给另外一个程序,目前不管java连接成功或是不成功,该存储过程都会写入数据!
目前需要在java连接不成功的情况下,有何方法能使存储过程 ......
怎样在Eclipse控制台中输入 java base
然后通过args[]输出
Java code:
public static void main(String[] args){
String str;
BufferedReader stdin = new BufferedReader(new InputS ......