用Java进行文件上传(带进度条) [英] File Upload with Java (with progress bar)
问题描述
JFileChooser
对象来选择一个文件,它可以方便的返回一个 File
对象。但是我想知道接下来会发生什么。我知道 File.length()
会给我文件的总大小(以字节为单位),但是如何发送选定的 File
到网络,我如何监视已经发送了多少字节?感谢提前。我最终绊倒了一个开源的Java上传器小程序,发现了我需要知道的一切。这里有链接到一个博客文章,描述它以及来源:
Article I'm extremely new to Java, and have mostly just been teaching myself as I go, so I've started building an applet. I'd like to make one that can select a file from the local disk and upload it as a multipart/form-data POST request but with a progress bar. Obviously the user has to grant permission to the Java applet to access the hard drive. Now I've already got the first part working: the user can select a file using a I ended up stumbling across an open source Java uploader applet and found everything I needed to know within its code. Here are links to a blog post describing it as well as the source: 这篇关于用Java进行文件上传(带进度条)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
rel =noreferrer / p> JFileChooser
object, which conveniently returns a File
object. But I'm wondering what comes next. I know that File.length()
will give me the total size in bytes of the file, but how do I send the selected File
to the web, and how do I monitor how many bytes have been sent? Thanks in advance.