import java.net.URLConnection;
import java.net.URL;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.FileOutputStream;
import java.io.File;
public class Download{
public static void main (String[] args){
try{
URLConnection conn = new URL("http://dl.jatt.link/hd.jatt.link/5239387a7e84528f196bbffde0b11054/kcizv/Aaja%20Na%20Ferrari%20Mein-(Mr-Jatt.com).mp3").openConnection();
InputStream is = conn.getInputStream();
OutputStream outstream = new FileOutputStream(new File("C:/Users/srini/Music/output.mp3"));
byte[] buffer = new byte[4096];
int len;
while ((len = is.read(buffer)) > 0) {
outstream.write(buffer, 0, len);
}
outstream.close();
}
catch(Exception e){
System.out.print(e);
}
}
}
================================================================
package sree;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.Charset;
public class Download1 {
public static void main (String[] args){
try{
String myUrl= "http://dl.smp3dl.com/files/data/4874/01%20Maana%20Ke%20Hum%20Yaar%20Nahi.mp3";
BufferedReader br = new BufferedReader(new InputStreamReader(((HttpURLConnection) (new URL(myUrl)).openConnection()).getInputStream(), Charset.forName("UTF-8")));
BufferedWriter bw = new BufferedWriter(new FileWriter(new File("C:/Users/mobigesture/Music/sree.mp3")));
String l;
while((l=br.readLine())!=null){
bw.write(l);
System.out.println("Downloading..........");
}
bw.close();
System.out.println("Download completed....");
}catch(Exception e){
System.out.print(e);
}
}
}
============================================================
No comments:
Post a Comment