我通過filenamechooser取得文件名,並將它發送給我想要的處理方法,但問題是它不接受文件名。我正在使用JPcap打開文件。當我硬編碼,它給了我完美的效果,但是當我發送的文件名也給我exception.Here是我的代碼Java:文件沒有打開給出例外
JpcapCaptor captor = JpcapCaptor.openFile("E:\\10.pcap");
我把這個文件的打印語句,這讓我這個
System.out.println("E:\\10.pcap");
在控制檯上我得到這個
E:\ 10.pcap
但是當我從我的GUI發送此文件名來此OPENFILE功能,它給了我這個例外,雖然當我把這個文件名,它也是相同的E的打印語句:\ 10 .pcap
SEVERE: null
java.io.IOException: E:\10.pcap
: Invalid argument
at jpcap.JpcapCaptor.openFile(JpcapCaptor.java:93)
at dpi.Functions.PortBasedAnalysis(Functions.java:52)
at dpi.GraphicalInterface.jButton1MouseClicked(GraphicalInterface.java:104)
at dpi.GraphicalInterface.access$000(GraphicalInterface.java:25)
at dpi.GraphicalInterface$1.mouseClicked(GraphicalInterface.java:49)
at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:253)
at java.awt.Component.processMouseEvent(Component.java:6041)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
at java.awt.Component.processEvent(Component.java:5803)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4410)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3995)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2429)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
爲了更好地幫助越早,張貼[SSCCE(http://sscce.org/)。 – 2012-02-14 05:55:24