• Post Reply Bookmark Topic Watch Topic
  • New Topic

Download a file from a https: website  RSS feed

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 {
java.io.BufferedInputStream in =
new java.io.BufferedInputStream(
new java
java.io.FileOutputStream fos =new java.io.FileOutputStream("c:/bankInfo.txt");
java.io.BufferedOutputStream bout = new BufferedOutputStream(fos, 1024);
byte[] data = new byte[1024];
int x = 0;
while ((x = in.read(data, 0, 1024)) >= 0) {
bout.write(data, 0, x);
System.out.println("File Downloaded");
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!