[英]Upload file using windows Explorer
I need a way to open windows file explorer to upload file to a desktop application. 我需要一种打开Windows文件资源管理器的方法,以将文件上传到桌面应用程序。 what i'm trying to do is press upload button then windows explorer pop-up and then i select a file to upload it into the database so what i'm asking is how to open windows explorer to do it.
我想做的是按下上传按钮,然后弹出Windows资源管理器,然后我选择一个文件将其上传到数据库中, 所以我要问的是如何打开Windows资源管理器来执行此操作。 i cant find any reference to this in java SE.
我在Java SE中找不到对此的任何引用。 if you know at-least have any reference, that should be enough for me.
如果您至少知道任何参考,那对我来说应该足够了。
All you need is a jFileChooser: 您只需要一个jFileChooser:
http://docs.oracle.com/javase/7/docs/api/javax/swing/JFileChooser.html http://docs.oracle.com/javase/7/docs/api/javax/swing/JFileChooser.html
Use the below snippet to implement what you're looking for, 使用以下代码片段实现您想要的功能,
JFileChooser fc = new JFileChooser();
int returnVal = fc.showOpenDialog(FileChooserDemo.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
//This is where a real application would open the file.
System.out.println("Opening: " + file.getName());
} else {
System.out.println("Open command cancelled by user.");
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.