1
我通過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)
你逃避你是從文件選擇獲取路徑的文件選擇器返回的路徑修剪()函數? – Rocky 2012-02-16 06:32:57
@Rocky我提到了路徑 – Xara 2012-02-16 06:34:29
您是否從您從File Chooser獲得的路徑上嘗試了trim()? – Rocky 2012-02-16 06:35:58