利用输出流,生成并在在本地保存图片

			import java.text.SimpleDateFormat;
			import java.util.Date;
			import java.io.File;
			import javax.imageio.stream.FileImageOutputStream;




			byte[] ry_zp = (byte[])blob.get("ry_zp");//数据库图片已bolb类型存储,取出来后转成byte数组
			Date date = new Date();
			String time = new SimpleDateFormat("yyyy-MM-dd").format(date);
			String url = "D:\\alarmImages\\"+time+"\\";
			System.out.println(url);
			File parent = new File(url);
			if(!parent.exists()|| !parent.isDirectory()) {
			    boolean mkdirs = parent.mkdirs();
			    System.out.println(mkdirs);
			}
			String imgname = time+ ".jpg";
			try{
			    FileImageOutputStream imageOutput = new FileImageOutputStream(new File(url+imgname));//打开输入流
			    
			     imageOutput.write(ry_zp, 0, ry_zp.length);//将byte写入硬盘
			    
			    imageOutput.close();
			    System.out.println("Make Picture success,Please find image in " + url);
			} catch(Exception ex) {
			    System.out.println("Exception: " + ex);
			    ex.printStackTrace();
			}
上一篇:求 n 以内的素数和以及素数个数


下一篇:Sqlmap