我正在开发车辆存储应用程序。其中一项功能是能够在远程服务器上以不同格式(word,excel,pdf)存储文档,而无需将服务器映射为单独的驱动器。
如果要打开的文件位于本地硬盘驱动器上(即“C:/Documents/FileToOpen.docx”),一切正常,但我无法弄清路径的路径结构(即“C :/Documents/FileToOpen.docx“在服务器”SERVER06“上)。我已经尝试过“//SERVER06/C/Documents/FileToOpen.docx”及其排列,但迄今为止没有喜悦。在远程服务器上打开文件[路径问题]
public class Attachments extends javax.swing.JFrame {
String docPath = "C:/Program Files/Microsoft Office/Office14/WINWORD.EXE";
String excelPath = "C:/Program Files/Microsoft Office/Office14/EXCEL.EXE";
String pdfPath = "C:/Program Files/Adobe/Reader 11.0/Reader/AcroRd32.exe";
/**
* Creates new form Attachments
*/
public Attachments() {
initComponents();
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
this.setResizable(false);
}
public void setList(Set attachmentList) {
DefaultListModel model = new DefaultListModel();
Iterator i = attachmentList.iterator();
int counter = 0;
while (i.hasNext()) {
model.add(counter, (Attachment) i.next());
counter++;
}
listAttachments.setModel(model);
}
//form generation
private void btnViewActionPerformed(java.awt.event.ActionEvent evt) {
Attachment a = (Attachment) listAttachments.getSelectedValue();
String type = a.getAttachmentUrl().substring(a.getAttachmentUrl().indexOf("."));
String prog = "";
if (type.substring(0, 2).equals(".d")) {
prog = docPath;
} else if (type.substring(0, 2).equals(".p")) {
prog = pdfPath;
} else if (type.substring(0, 2).equals(".x")) {
prog = excelPath;
}
String commandString = "\"" + prog + "\" \"" + a.getAttachmentUrl() + "\"";
Runtime rt = Runtime.getRuntime();
try {
rt.exec(commandString);
} catch (IOException ex) {
System.out.println(ex.getMessage());
ex.printStackTrace();
}
}
private void jButtonCloseActionPerformed(java.awt.event.ActionEvent evt) {
this.setVisible(false);
this.dispose();
}
有没有办法做到这一点?
TCP/IP,我相信。 –