开发者

Groovy download files [closed]

开发者 https://www.devze.com 2023-01-27 08:10 出处:网络
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post.
Closed. This question needs details or clarity. It is not currently accepting answers.

Want to improve this question? Add details and clarify the problem by editing this post.

Closed 4 years ago.

开发者_JAVA百科 Improve this question

I just had a quick question about downloading files. I was reading this page:

http://groovy.codehaus.org/Simple+file+download+from+URL

Can someone explain what the difference is between the two ways explained on that page? (Aside from overriding the leftshift operator) Is there any significance for doing it one way or the other?


The former method is far cleaner and is what you would do in most cases.

The second is effectively enhancing the File object within the use closure. I can't see where it would be useful in this context, but say in your code you were often putting content from urls into files, or you had a dsl where you wanted to allow for that functionality, you could use categories to extend the file object.

Personally, I see the example as really just showing (a rather impractical) use for categories.

0

精彩评论

暂无评论...
验证码 换一张
取 消