indiTraders - Forum for the Active Indian Trader  

Go Back   indiTraders - Forum for the Active Indian Trader > Tools > Software > Other Platforms

Reply
 
Bookmark and Share LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 27-09-2015, 11:16 AM
nTP's Avatar
nTP nTP is offline
Flash Crash
 
Join Date: Dec 2013
Location: kolkata
Posts: 2,026
Thanks: 7,771
Thanked 2,208 Times in 1,320 Posts
nTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud ofnTP has much to be proud of
Default java based premitive (unformatted) downloader

Hi

this is simplest very primitive code.

Code:
package whatever;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;

/**
 * Java code to download a remote zip file and save it to a specific local folder.
 *
 * @since 22/9/15.
 */
class Main {
    public static void main(String[] args) {

        String saveTo = "/home/<xxxxx>/Desktop/foo/";
        new Thread(() -> {
            try {
                System.out.println("ATTEMPTING DOWNLOAD, PLEASE WAIT...");
                URL url = new URL("http://www.nseindia.com/archives/equities/bhavcopy/pr/PR240915.zip"); // Zip file to download
                URLConnection urlConnection = url.openConnection(); // Returns a URLConnection instance represents a connection to the remote object referred to by the URL.
                InputStream inputStream = urlConnection.getInputStream(); // Returns an input stream that reads from this open connection.
                FileOutputStream fileOutputStream = new FileOutputStream(saveTo + "PR240915.zip"); // Creates a file output stream to write to the file with the specified name.
                byte[] b = new byte[1024]; // Creates a new byte array.
                int count;
                while ((count = inputStream.read(b)) >= 0) {
                    fileOutputStream.write(b, 0, count);
                }
                System.out.print("DOWNLOAD COMPLETE!");
                fileOutputStream.flush();
                fileOutputStream.close();
                inputStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }).start();
    }
}
** add it with swing code **
** made by one of my frnz **
__________________
thx
nTuple

Disclaimer: I am not a Research Analyst and not registered with any regulating authority. All posts are for educational purpose only.

Consider us a dumb -dumble guy in this analysis, any type of real time example will be quick-learn approach.

Last edited by nTP; 27-09-2015 at 12:06 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
The Following User Says Thank You to nTP For This Useful Post:
Reply

indiTraders - Forum for the Active Indian Trader > Tools > Software > Other Platforms


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On



All times are GMT +5.5. The time now is 10:31 PM.


vBulletin Copyright by vBulletin

Content Relevant URLs by vBSEO 3.3.2