How to download and save a file from Internet using Java?

前端 未结 21 2889
情深已故
情深已故 2020-11-21 05:06

There is an online file (such as http://www.example.com/information.asp) I need to grab and save to a directory. I know there are several methods for grabbing a

21条回答
  •  广开言路
    2020-11-21 05:38

    There is method U.fetch(url) in underscore-java library.

    pom.xml:

      com.github.javadev
      underscore
      1.45
    

    Code example:

    import com.github.underscore.lodash.U;
    
    public class Download {
        public static void main(String ... args) {
            String text = U.fetch("https://stackoverflow.com/questions"
            + "/921262/how-to-download-and-save-a-file-from-internet-using-java").text();
        }
    }
    

提交回复
热议问题