1

I am taking a file name via filenamechooser and sending it it my desired method for processing but the problem is that it is not accepting the filename.I am using JPcap for opening up the file.When i hard code it ,It gives me perfect results but when i send the file name it gives me exception.Here is my code

     JpcapCaptor captor = JpcapCaptor.openFile("E:\\10.pcap");

I took the printing statement of this file and it gives me this

      System.out.println("E:\\10.pcap");

on Console i get this

E:\10.pcap

but when i send this filename from my GUI to this openfile function it gives me this exception although when i take the printing statement of this filename it is also the same 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)
Xara
  • 8,748
  • 16
  • 52
  • 82
  • Are you escaping the path you are getting from the File Chooser ? – Rocky Feb 16 '12 at 06:32
  • Did u try trim() on the path you were getting from the File Chooser ? – Rocky Feb 16 '12 at 06:35
  • @Rocky i have not used trim , whats that? – Xara Feb 16 '12 at 06:38
  • 1
    The path that is getting returned from the File Chooser may have some trailing white spaces , in order to remove them , you use the trim() function and I guess Mat is also suggesting the same below . – Rocky Feb 16 '12 at 06:41

1 Answers1

0

Try using the trim() function on the Path returned by File Chooser

Rocky
  • 941
  • 7
  • 11