Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Download a file from a https: website

Quang Pham
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can some one show me how to write a java program to download a file from a secure server https?
Currently I am able to download file from http but got certificate issue when trying to download from https.
Here is the code:
public static void main(String args[]) throws IOException { in =
new java
.URL("").openStream()); fos =new"c:/bankInfo.txt"); bout = new BufferedOutputStream(fos, 1024);
byte[] data = new byte[1024];
int x = 0;
while ((x =, 0, 1024)) >= 0) {
bout.write(data, 0, x);
System.out.println("File Downloaded");
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic