62,614
社区成员
发帖
与我相关
我的任务
分享
HttpURLConnection connection = (HttpURLConnection) new URL("http://www.uxin.com/captcha/index.html?t=" + new Date().getTime()).openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
InputStream response = connection.getInputStream();
byte[] buf = new byte[1024];
FileOutputStream out = new FileOutputStream("/Users/Biao/Desktop/x.html");
int len = 0;
while ((len = response.read(buf)) != -1) {
out.write(buf, 0, len);
}
out.flush();
out.close();
import javax.swing.*;
import java.net.MalformedURLException;
import java.net.URL;
public class Aloha extends JPanel {
private static void createAndShowGui() throws MalformedURLException {
ImageIcon icon = new ImageIcon(new URL("http://www.cppblog.com/images/cppblog_com/biao/Button.png"));
JLabel label = new JLabel(icon);
JFrame frame = new JFrame();
frame.getContentPane().add(label);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500, 500);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
createAndShowGui();
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
});
}
}