1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 网页生成图片快照

网页生成图片快照

时间:2023-01-31 22:31:56

相关推荐

网页生成图片快照

网页生成图片快照

源码地址:/juforg/websnapasimg

使用的核心开源项目:

DJNativeSwing1.0.3

DJNativeSwing-SWT1.0.3

org.eclipse.swt.win32.win32.x86_64 4.3

调用

请求地址

测试环境:http://localhost:7090/htmlsnapshot/snaphtml

调用方式GET

保存返回的图片流

HttpClient client =newHttpClient();HttpMethod get =newGetMethod("http://localhost:8081/htmlsnapshot/snaphtml?htmlUrl=http%3A%2F%%3A8080%2Fydmobile%2Fbpsfinance%2Fzhengzhaosy%2F15346handler57090mbtmp.shtml&imgType=png");int status =-1;try{status = client.executeMethod(get);if(200== status){File file =newFile(path);//保存图片至本地的路径if(!file.getParentFile().exists()){file.getParentFile().mkdirs();}fos =newFileOutputStream(file);in = get.getResponseBodyAsStream();//获取流out =newBufferedOutputStream(fos);int i;while((i=in.read())!=-1){out.write(i);}out.flush();out.close();in.close();System.out.println("生成文件:"+path);}}catch(Exception e){;}finally{//释放资源get.releaseConnection();try{if(null!=out){out.close();}if(null!=in){in.close();}}catch(IOException e){e.printStackTrace();}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。