㈠ java關於下載圖片。
URL url = new URL("圖片地址");
File outFile = new File(「圖片保存到本地路徑」);
OutputStream os = new FileOutputStream(outFile);
InputStream is = url.openStream();
byte[] buff = new byte[1024];
while(true) {
int readed = is.read(buff);
if(readed == -1) {
break;
}
byte[] temp = new byte[readed];
System.array(buff, 0, temp, 0, readed);
os.write(temp);
}
is.close();
os.close();
㈡ JAVA 畫圖片
如果image是在同一個包下的話,可以直接在路勁上寫你的image的名字。比如包名叫com..chaojunjie 那麼下面有個Test.java,在裡面再加一張圖片test.image,那麼久直接Toolkit.getDeafaultToolkit.getImage('test.image')就可以了。當然這樣寫不是做好的。最好單獨和src同目錄下建個包叫images然後把拓片單獨放裡面。
然後獲得相對路徑Toolkit.getDeafaultToolkit.getImage(this.getClass.getFile('裡面寫你的包名+圖片名'))
㈢ JAVA圖片輸出
等著拿分.......
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.font.FontRenderContext;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
/**
* @author alanwei
*
*/
public class Test {
public static BufferedImage createImage(int width, int height, String s) {
Font font = new Font("Serif", Font.BOLD, 10);
BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = (Graphics2D)bi.getGraphics();
g2.setBackground(Color.WHITE);
g2.clearRect(0, 0, width, height);
g2.setPaint(Color.RED);
g2.drawString(s, 0, 5 + height / 2);
return bi;
}
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
BufferedImage image = createImage(100, 20, "123456789");
File file = new File("image.jpg");
if (!file.exists()) {
file.createNewFile();
}
if (image != null) {
ImageIO.write(image, "jpg", file);
}
}
}
㈣ java 圖片
packagetool;
importjava.awt.BorderLayout;
importjava.awt.event.ActionEvent;
importjava.awt.event.ActionListener;
importjavax.swing.ImageIcon;
importjavax.swing.JButton;
importjavax.swing.JFrame;
importjavax.swing.JLabel;
importjavax.swing.SwingUtilities;
publicclassAextendsJFrame
{
=1L;
JLabeljlabel=newJLabel("無聊");
staticAa=newA();
publicstaticvoidmain(String[]args)
{
Bb=a.newB();
a.setLayout(newBorderLayout());
a.add(a.jlabel,"Center");
a.add(b.jb,"South");
a.setSize(200,200);
a.setLocationRelativeTo(null);
a.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
a.setVisible(true);
}
{
JButtonjb=newJButton("無聊透頂");
publicB()
{
jb.addActionListener(this);
}
@Override
publicvoidactionPerformed(ActionEvente)
{
a.jlabel.setIcon(newImageIcon(A.class.getResource("../image/soccer.jpg")));
SwingUtilities.updateComponentTreeUI(a);
}
}
}
㈤ java通過百度地圖 獲取靜態圖片 如何保存到本地
通過正則表達式,從頁面將圖片偷下來,保存到本地即可。給你個例子
public class RegexDemo1 {
public static void main(String[] args) throws Exception{
//創建URL
URL url=new URL("http://hunan.haodf.com/");
//打開連接
URLConnection conn=url.openConnection();
//創建輸入流
InputStream is=conn.getInputStream();
InputStreamReader isr=new InputStreamReader(is);
BufferedReader br=new BufferedReader(isr);
//讀數據
String line=null;
String allLine="";
line=br.readLine();
while(line!=null){
allLine+=line;
line=br.readLine();
}
//關閉流
br.close();
isr.close();
is.close();
System.out.println(allLine);
Pattern p=Pattern.compile("(?<=<td width=\"30%\">\\s{0,100}?.{0,100}?\\.htm\\\">).+?(?=</a>\\s*?</td>)");
Matcher m=p.matcher(allLine);
int num=0;
while(m.find()){
System.out.println(m.group());
num++;
}
System.out.println(num);
}
}
這個是我自己寫的,你參考下吧
㈥ 如何下載java圖片
你好,UC上網顯示不出圖片可能是你在設置UC的時候把UC設置成無圖瀏覽的了吧只能在線下載 下載好安裝 JAVA 三星的機子都是這樣的。 O(∩_∩)O~ ..
㈦ java圖片
絕對是路徑的問題,
㈧ JAVA添加圖片
JAVA是非常靈活的語言,你自己稍動一下手指就能編個控制項的。
class ImageBox extends JLabel ...
㈨ Java圖片瀏覽器
Java圖片瀏覽器可以用apache的圖片處理
㈩ java圖片處理
使用Java動態處理圖片非常方便,可以用於很多應用場合,比如動態輸入股市線,縮略圖,動態banner圖片、動態的界面風格等等。筆者也在
java圖片處理: