How To Download From Pdb (Ftp)Website Using Java Codes?
3
3
Entering edit mode
14.4 years ago
User 4686 ▴ 220

Hi all, I am doing a project on downloading of protein files from pdb (ftp)website by using java codes. Does anyone know how I can go about doing this?

pdb • 5.0k views
ADD COMMENT
4
Entering edit mode
14.4 years ago

See Read from URL

ADD COMMENT
0
Entering edit mode
14.4 years ago

If you can use non Java solution, you may take a look at the FTP page at PDB. If you are looking to download complete data, PDB provides shell scripts to download and maintain PDB files. One of the script use rsync for the download.

ADD COMMENT
0
Entering edit mode

hi khader, im sorry to say that I can only use java to go about downloading the files from there. Are there any source of help that I can get from anywhere?

ADD REPLY
0
Entering edit mode

I am sure that you can call the system commands from Java using run time execution function(I use system or `` in Perl) in Java. As the ftp script provided by RCSB is in shell script, you may easily call them via your Java program.

ADD REPLY
0
Entering edit mode
11.9 years ago

Here is the suitable Java code fragment. It reads from URL and saves to some location on the local folder.

URL u = new URL("http://.....");
InputStream in = url.openStream();
byte [] buffer = new byte[4024];
int n;
FileOutputStream out = new FileOutputStream("...");
// Read at most buffer.length bytes into buffer, returns the number of bytes actually read or -1 on eof.
while ( (n = in.read(buffer)) > 0) {
    // Only write  the newly read bytes. 
    out.write(buffer, 0, n);
 }
out.close();
in.close();
ADD COMMENT

Login before adding your answer.

Traffic: 2264 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6