使用程序保存网页中的图片 网络读取图片

news/2024/7/4 1:44:40 标签: 网络, file, exception, url, string, class
class="baidu_pl">
class="article_content clearfix">
class="htmledit_views">

使用程序保存网页中的图片 class="tags" href="/tags/WangLuo.html" title=网络>网络读取图片

 

package com.pp;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
public class test2 {
 public static void main(String[] args) {
  File class="tags" href="/tags/FILE.html" title=file>file = new File("C://javalogo.gif");
  OutputStream os = null;
  try{
  URL class="tags" href="/tags/URL.html" title=url>url = new URL("http://ef.icoupon.com.cn/admin/upload/uploadimage/2009/6/20096181424423.png");
  InputStream is = class="tags" href="/tags/URL.html" title=url>url.openConnection().getInputStream();
  class="tags" href="/tags/FILE.html" title=file>file.createNewFile();
  os = new FileOutputStream(class="tags" href="/tags/FILE.html" title=file>file);
  int b = is.read();
  while (b != -1){
  os.write(b);
  b = is.read();
  }
  is.close();
  os.close();
  System.out.println("图片javalogo.gif保存成功");
  }catch(Exception e){
  e.printStackTrace();
  System.out.println(e);
  }
  }

}

 

 


http://www.niftyadmin.cn/n/1425287.html

相关文章

jsf传值

从一个页面到另一个页面用request,也就是param <f:param value"#{bookBagBean.bookBag.bookid}" name"bookid"></f:param>取值${param.bookid}

利用样式控制表格

css样式|如何利用css样式表格<html><head><meta http-equiv"Content-Type" content"text/html; charsetgb2312"><title>无标题文档</title><style type"text/css"><!--#data{font-size: 12px;border: 1p…

Js为Tr直接添加onmouseover事件

Js为Tr添加onmouseover事件jquery加入到工程中&#xff08;见csdn空间&#xff16;/js/jquery.js&#xff09;<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1- transitional.dtd"><h…

解决多个一对一关系会死锁的问题(数据库连接池C3P0)

hibernate 1 对多 死锁springhibernatestruts SQL 数据库频繁死锁。只要执行update 后 查询就死锁&#xff0c;数据库 死了&#xff0c;要把tomcat停了才能继续运行。 解决方法&#xff1a;用数据库连接池C3P0解决 <bean id"dataSource" class"com.mch…

样式复习

在html中写好的样式&#xff0c;到jsp中就变形了&#xff0c;到处找人问&#xff0c;别人都不知道 最后尽然是因为在css中写了注释的原因&#xff0e;把注释去掉就好了&#xff0e; css中不能有注释&#xff0f;&#xff0a;&#xff0a;&#xff0f;倒&#xff0e;&#xff…

jsf批量删除

jsf批量删除<input type"checkbox" id"checkAll" /> <input type"checkbox" name"oids" id"oo" value"${project.ID}" /><h:commandLink action"#{projectBean.deleteMultiProject}…

普通文本框也有格式 样式

普通文本框也有格式public String getShowIntro() { return intro.replaceAll("//n","<br>").replaceAll(" ", " "); }

机器学习算法_MATLAB机器学习:机器学习算法的分类

机器学习算法的能力来源于算法的质量,这正是过去这些年科学家着力更新、改进的内容。这些算法根据使用的输入数据、训练方式以及学习到的模型的输出结果,可分为如下3类。(1)监督学习:这类算法根据一系列样本(每个样本的输入有对应的输出)的观测结果建立从输入到输出的映射关系,…