Comfortable download with JAVA

Automate downloading files on the Internet with Java I might use it again

If the file folder has regular URL, you can drop it by turning it with a for statement. I was careful not to put a load on the other server

Reflesh.java


import java.net.*;
import java.io.*;

public class Reflesh {
    public Reflesh(){
        for(int k=1;k<100;k++){
            try {
                URL url = new URL("http://www.~~~~~~.com/music/"+k+".mp3");
                URLConnection conn = url.openConnection();
                InputStream in = conn.getInputStream();
                File file = new File("/Users/mp3/mp3_"+k+".mp3");
                FileOutputStream out = new FileOutputStream(file, false);
                int b;
                while((b = in.read()) != -1){
                    out.write(b);
                }
                out.close();
                in.close();
            }catch(MalformedURLException e){
                System.out.println("mal");
                continue;
            }catch(IOException e) {
                System.out.println("io");
                continue;
            }
        }
    }
    public static void main(String args[]) {
        new Reflesh();
    }
}

Recommended Posts

Comfortable download with JAVA
Download Java with Ansible
Install java with Homebrew
Change seats with java
Install Java with Ansible
Make Java code coverage more comfortable with Jacoco 0.8.0
Switch java with direnv
Let's scrape with Java! !!
Build Java with Wercker
Download with Spring Boot
Endian conversion with JAVA
[Tutorial] Download Eclipse → Run the application with Java (Pleiades)
[Tutorial] Download Eclipse → Run Web application with Java (Pleiades)
Easy BDD with (Java) Spectrum?
Use Lambda Layers with Java
Java multi-project creation with Gradle
Java Config with Spring MVC
Let's experiment with Java inlining
[Template] MySQL connection with Java
Rewrite Java try-catch with Optional
Install Java 7 with Homebrew (cask)
[Java] JSON communication with jackson
Java to play with Function
Try DB connection with Java
Enable Java EE with NetBeans 9
[Java] JavaConfig with Static InnerClass
Try gRPC with Java, Maven
Let's operate Excel with Java! !!
Version control Java with SDKMAN
RSA encryption / decryption with java 8
Paging PDF with Java + PDFBox.jar
Sort strings functionally with java
Object-oriented (java) with Strike Gundam
[Java] Content acquisition with HttpCliient
Java version control with jenv
Troubleshooting with Java Flight Recorder
Streamline Java testing with Spock
Connect to DB with Java
Connect to MySQL 8 with Java
Error when playing with java
Using Mapper with Java (Spring)
Java study memo 2 with Progate
Getting Started with Java Basics
Seasonal display with Java switch
Use SpatiaLite with Java / JDBC
Study Java with Progate Note 1
Compare Java 8 Optional with Swift
HTML parsing with JAVA (scraping)
Run Java VM with WebAssembly
Screen transition with swing, java
Java unit tests with Mockito
[Java 8] Duplicate deletion (& duplicate check) with Stream
Create an immutable class with JAVA
Java lambda expressions learned with Comparator
[Java, Scala] Image resizing with ImageIO
Install java with Ubuntu 16.04 based Docker
Java to learn with ramen [Part 1]
Use java with MSYS and Cygwin
Distributed tracing with OpenCensus and Java
100% Pure Java BDD with JGiven (Introduction)
Install Java and Tomcat with Ansible