how to download external files in gradle?

前端 未结 7 537
你的背包
你的背包 2020-12-02 09:50

I have a gradle project which requires some data files available somewhere on the internet using http. The goal is that this immutable remote file is pulled once upon first

7条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-02 10:38

    How about just:

    def f = new File('the file path')
    if (!f.exists()) {
        new URL('the url').withInputStream{ i -> f.withOutputStream{ it << i }}
    }
    

提交回复
热议问题