-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSendFile.java
More file actions
38 lines (27 loc) · 849 Bytes
/
SendFile.java
File metadata and controls
38 lines (27 loc) · 849 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.server.util;
import java.awt.FileDialog;
import javax.swing.JFrame;
public class SendFile extends JFrame{
public static String name = null;
private static final long serialVersionUID = 1L;
public static String fileName = null;
// 选择打开文件
public String getFile() {
//打开一个FileDialog,设置标题和模式(读取文件)
FileDialog fd = new FileDialog(this, "请选择要传给zpc的文件", FileDialog.LOAD);
//设置打开对话框的根目录
fd.setDirectory("C:\\");
fd.setVisible(true);
/*
* 当用户选择了取消按钮,则返回null
*/
if (fd.getFile() != null) {
//获取文件的全文件名
fileName = fd.getDirectory()+fd.getFile();
name = fd.getFile();
System.out.println("已选择打开 " + fileName);
}
//返回文件全路径
return fileName;
}
}