呈现到页面是图像的2进制数据,不是<img src="./directory/**.jpg"/>java获取二进制流
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.net.URL;public class Test {
public static void main(String[] args) throws Exception {
//代理上网????
Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("","".toCharArray());
}
});
URL url = new URL("http://image.58.com/showphone.aspx?t=v55&v=DD22F84EF54BCE639D5451238F35CCF3");
InputStream is = url.openStream();
FileOutputStream fos = new FileOutputStream("c:\\test.jpg");
byte data[] = new byte[is.available()];
is.read(data);
fos.write(data);
fos.close();
}
}
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.net.URL;public class Test {
public static void main(String[] args) throws Exception {
//代理上网????
Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("","".toCharArray());
}
});
URL url = new URL("http://image.58.com/showphone.aspx?t=v55&v=DD22F84EF54BCE639D5451238F35CCF3");
InputStream is = url.openStream();
FileOutputStream fos = new FileOutputStream("c:\\test.jpg");
byte data[] = new byte[is.available()];
is.read(data);
fos.write(data);
fos.close();
}
}
解决方案 »
- 新人问题:实际项目中,class是不是基本一律声明为public?
- 关于集合类的问题
- tableChanged(TableModelEvent e)事件问题
- 一个关于用户名密码读取写入的问题~~~
- 请问如何在java中导如入用3DMAX做成的.MAX模型???
- 用过sun.net.ftp.FTPClient的兄弟请进...
- 请问java中如何获得windows的系统目录?
- javax.swing.JTable问题,怎样给运行时动态添加的Column设置它的表头文本Title?
- apache&tomcat?
- 请问:如何把一个方法作为另一个方法的参数?举个例子最好
- [讨论]java有什么魅力让你放弃VC++,大家讨论一下
- 跟swt相比,twaver的优点在那儿?
防盗链的
如果你是想知道怎样做防盗
如果想破这个58的防盗,那不知道