java snapshot是什么?讓我們一起來了解一下吧!?
首先java snapshot是指Java maven程序中的快照。而快照是一個非常特別的版本,設定了某個現在的開發進度的副本。與一般的版本不同,maven開源項目每次會隨著代碼的更新而發布快照。
SNAPSHOT作用:
1.標識jar是一個不穩定的文件項目,起標識版本的作用。
2.運用SNAPSHOT之后,maven會常常去私服或是中央倉庫中拉取最新的這個jar的版本;而沒有SNAPSHOT的jar,則會從本地倉庫中查找,本地不存在,才去中央倉庫中拉取。
3.更新頻率:需要在pom.xml文件中進行配置。
java實現網頁快照需要的具體代碼如下:
??????? import?java.awt.Graphics2D; import?java.awt.RenderingHints; import?java.awt.geom.AffineTransform; import?java.awt.image.BufferedImage; import?java.awt.image.ColorModel; import?java.awt.image.WritableRaster; import?java.io.*; import?javax.imageio.*; import?javax.swing.*; /** ?*?HTML2JPG,HTML頁面轉圖片的實現方法。 ?*? ?*?@author?老紫竹(Java世紀網,java2000.net) ?*/ public?class?Test?extends?JFrame?{ ??public?Test(String?url,?File?file)?throws?Exception?{ ????JEditorPane?editorPane?=?new?JEditorPane(); ????editorPane.setEditable(false); ????editorPane.setPage(url); ????JScrollPane?jsp?=?new?JScrollPane(editorPane); ????getContentPane().add(jsp); ????this.setLocation(0,?0); ????this.setVisible(true);?//?如果這里不設置可見,則里面的圖片等無法截取 ???? ????//?如果不延時,則圖片等可能沒有時間下載顯示 ????//?具體的秒數需要根據網速等調整 ????Thread.sleep(5?*?1000); ????setSize(10000,?10000); ????pack(); ????//?BufferedImage?image?=?new?BufferedImage(editorPane.getWidth(), ????//?editorPane.getHeight(),?BufferedImage.TYPE_INT_RGB); ????BufferedImage?image?=?new?BufferedImage(editorPane.getWidth(),?editorPane.getHeight(), ????????BufferedImage.TYPE_INT_RGB); ????Graphics2D?graphics2D?=?image.createGraphics(); ????editorPane.paint(graphics2D); ???? ????BufferedImage?image1?=?resize(image,?600,?400); ????ImageIO.write(image1,?"jpg",?file); ????dispose(); ??} ??public?static?void?main(String[]?args)?throws?Exception?{ ????new?Test("http://www.google.cn",?new?File("d:/file.jpg")); ??} ??public?static?BufferedImage?resize(BufferedImage?source,?int?targetW,?int?targetH)?{ ????//?targetW,targetH分別表示目標長和寬 ????int?type?=?source.getType(); ????BufferedImage?target?=?null; ????double?sx?=?(double)?targetW?/?source.getWidth(); ????double?sy?=?(double)?targetH?/?source.getHeight(); ????//?這里想實現在targetW,targetH范圍內實現等比縮放。如果不需要等比縮放 ????//?則將下面的if?else語句注釋即可 ????if?(sx?>?sy)?{ ??????sx?=?sy; ??????targetW?=?(int)?(sx?*?source.getWidth()); ??????//?}?else?{ ??????//?sy?=?sx; ??????//?targetH?=?(int)?(sy?*?source.getHeight()); ????} ????if?(type?==?BufferedImage.TYPE_CUSTOM)?{?//?handmade ??????ColorModel?cm?=?source.getColorModel(); ??????WritableRaster?raster?=?cm.createCompatibleWritableRaster(targetW,?targetH); ??????boolean?alphaPremultiplied?=?cm.isAlphaPremultiplied(); ??????target?=?new?BufferedImage(cm,?raster,?alphaPremultiplied,?null); ????}?else ??????target?=?new?BufferedImage(targetW,?targetH,?type); ????Graphics2D?g?=?target.createGraphics(); ????//?smoother?than?exlax: ????g.setRenderingHint(RenderingHints.KEY_RENDERING,?RenderingHints.VALUE_RENDER_QUALITY); ????g.drawRenderedImage(source,?AffineTransform.getScaleInstance(sx,?sy)); ????g.dispose(); ????return?target; ??} }
以上就是小編今天的分享了,希望可以幫助到大家。