Opening file using JFileChooser with File filtering

ok guys I am trying set a file filter object to my file chooser it compile but i have a run time error, the error says:
Exception in thread "AWT-EventQueue-0" java.land.IllegalArgurmentException: Extension must be non-null and not empty
at javax.swing.filechooser.FileNameExtensionFilter..........
I have declared
JFileChooser jfc = new JFileChooser();
as a global variable
and in to my ActionListener, ActionPerform the following:
ActionListener listener = new ActionListener()
          String selection, file, copy;
     public void actionPerformed(ActionEvent e)
int tipe =0, size = 16;
     String Stile = " ";
     if (e.getSource() == openItem)
          FileNameExtensionFilter filter = new FileNameExtensionFilter("txt");
jfc.setFileFilter(filter);
          jfc.showOpenDialog(null);
          try
          File f = jfc.getSelectedFile();
          String file = f.getAbsolutePath();
          File f2 = new File(file);
          BufferedReader in = new BufferedReader(new FileReader(f2));
          String text = "";
String textl = text;
while( text != null)
               text = in.readLine() ;
               textl = textl + text + "\n";
               System.out.println(text);
Can some one please tell me whats wrong? and if possible how to fix it? Thank you guys

A couple of things might help:
It's a good idea to post the entire stack trace (even though it may appear a bit long). Specifically it helps to know which line in your code triggered the runtime error. You read the stack trace down from the top and the first line you find belonging to your code is a good place to begin looking hard at.
Another debugging technique is the SSCCE. The idea with this is that you come up with a really brief example illustrating your problem. (ie it compiles, runs and spits out the runtime error). It can be made brief by getting rid of anything extraneous to the problem. A bare button in a frame which when clicked sets up and displays the file chooser should be enough. I describe this as a debugging technique because in the course of constructing such things I often find I isolate - and therefore can see and fix - an error.
Anyway, sorry this is so general. Maybe someone will come along with a "missing semicolon in line 3"-type solution but, if not, it may be useful.

Similar Messages

  • I was given an assingment, but have no idea where to begin. The assingment is to create a text file using notepad with all of my digital inputs and some how make those imputs show up on my digital indicators on my control pannel

    I was given an assingment, but have no idea where to begin. The assingment is to create a text file using notepad with all of my digital inputs and some how make those imputs show up on my digital indicators on my control pannel.
    When it was explained to me it didn't sound to hard of a task, I have no LabVIEW experience and the tutortial sucks.

    StevenD: FYI, I did NOT give you the one star rating. I would never do that!
    StevenD wrote:
    Ow. Someone is grumpy today.
    Well, this is an assignment, so it is probably homework.
    Why else would anyone give HIM such an assigment, after all he has no LabVIEW experience and the tutorials are too hard for him?
    This would make no sense unless all of it was just covered in class!
    This is not a free homework service with instant gratification.
    OK! Let's do it step by step. I assume you already have a VI with the digital indicators.
    "...but have no idea where to begin".
    open notepad.
    decide on a format, possibly one line per indicator.
    type the document.
    close notepad.
    open LabVIEW.
    Open the existing VI with all the indicators.
    (are you still following?)
    look at the diagram.
    Who made the program?
    Does the code make sense so far?
    Is it a statemachine or just a bunch of crisscrossed wires?
    Where do you want to add the file read?
    How should the file be read (after pressing a read button, at the start of the program ,etc.)
    See how far you get!
    Message Edited by altenbach on 06-24-2008 11:23 AM
    LabVIEW Champion . Do more with less code and in less time .

  • I need to open and use a DFX file in Illustrator CS6 only displaying digits and letters

    I need to open and use a DFX file in Illustrator CS6 but it is only displaying digits and letters as opposed to fashion patterns. I believe the original file was  created in Gerber

    Thank you.
    I will see if I can access/download a CS2 version. Thats a kind offer, I will see how I go with the download first, as I will be needing to open several files over the next few weeks.
    Maxine

  • Need to avoid header When using GUI_DOWNLOAD with file type "DBF"

    Hi ,
    I am downloading internal table to excel on the desktop using GUI_DOWNLOAD with file type "DBF".
    Internal table I use do not have any header.
    But I do see the header in the downloaded file.
    It displays 1 row as " F1  F2 F3..ETC" heading for each column.
    Is there any variable we need to set to suppress header.
    Thank you,
    Kumar

    Hello Dilip,
    I tried using GUI_DOWNLOAD with FILE TYPE as "DBF", and i see the problem as mentioned. My question to you is:
    1. Why do you need 'DBF' format?
    2. Is it required to save the file as '.CSV'? Can you not try to save in '.XLS' file?
    Plz revert back.
    BR,
    Suhas

  • Need to remove header When using GUI_DOWNLOAD with file type "DBF"

    Hi ALL,
    I am using GUI_DOWNLOAD function module to downlaod data to csv file . I have taken FILE TYPE as "DBF" . After download , I have found data is downloaded along with a default header . Now how can I avoid Header while downloading.
    Please help me to solve this problem.
    thanks and regards,
    Dilip
    Edited by: dilip kumar on Jun 9, 2009 11:51 AM

    Hello Dilip,
    I tried using GUI_DOWNLOAD with FILE TYPE as "DBF", and i see the problem as mentioned. My question to you is:
    1. Why do you need 'DBF' format?
    2. Is it required to save the file as '.CSV'? Can you not try to save in '.XLS' file?
    Plz revert back.
    BR,
    Suhas

  • File Sender adapter with File content conversion

    Hi
    I'm having problems picking up a flat file that has some junk characters in the file.
    I'm usign a file sender adapter with file content conversion. The adapters shows the following error-
    Conversion of complete file content of  to XML format failed around position 0: sun.io.MalformedInputException
    this is the sample data with junk char's -
    A20099201009999009999060815160505051700130008151vÿÿÿÿ³  r 0OK0476                     31N016227241915840IV  00840 ÿÿÿ ÿ ÿÿÿÿÿÿÿÿ ÿ ÿÿÿ             
    There is not much in the file content conversion. This is a fixed length file, I'm just pickign it up & passing it to an inbound proxy. All my processing is in the proxy.
    I'd appreciate any suggestions.
    Thanks
    Rachana

    Hi Rachana,
    Do you use a specific "encoding" like UTF-8 or ISO-8859-1 in your Sender CC?
    To be simple, Encoding is linked to country, you can find all "iso-nnnn" via google or some of them in sap help.
    http://help.sap.com/saphelp_nw2004s/helpdata/en/e3/94007075cae04f930cc4c034e411e1/content.htm
    Moreover, with your source file opened thanks to Notepad (for instance), use option "save UNDER", you will the encoding use by your file
    Mickael

  • Importing multiple files using the Import File menu.

    For some reason I am never able to add more the 5 mp3 files using the Import File menu. All of my files are located on the NAS device and if I select the Import Folder menu all the files in the folder will be imported. However, time after time I add more files to the same folder and then need to import just the new files to iTunes. For that I am using the Import File menu. If select more then 5 files, only 5 files will be imported. Some times I have 100 new files that I want to add, and moving 5 files a time is time consuming and painful. I try opening the folder, selecting all files and dropping them into iTunes, but that did not work. Is there a way to import more than 5 files at a time, or iTunes is not capable doing that?

    I am often surprised how many ways there are to add songs to iTunes. Selecting a number in the open file dialog must have a maximum string length for the file names. I bet that the path and file name are long on those songs and that is why you can only load 5 at a time from your NAS. What I have had luck with and is very easy is to select a group of songs and right click and "play" them. My iTunes is set to import and organize on play. The first song starts playing and they all load. I routinely do this with entire albums without problem.
    Paul

  • How to edit a line in a file using a batch file??????

    Basically i want to edit one line in a properties file, using a batch file, Here is what it says
    #Minecraft server properties
    #Tue Feb 22 15:58:36 PST 2011
    level-name=world2
    hellworld=false
    spawn-monsters=true
    online-mode=false
    spawn-animals=true
    max-players=5
    server-ip=5.196.238.77
    pvp=true
    server-port=25565
    white-list=false
    The IP address needs to be changed, i have a hamachi server and a server for home but i need to change this to my ip address on my computer wich is 192.168.1.74. This needs to be changed back and forth so how can i make a batch that just runs and then done its been changed.

    There are no .bat files in a Unix environment
    #!/usr/bin/env bash
    export NEW_IP=192.168.1.74
    perl -ni -e '
    s/d.d+.d+.d/$ENV{"NEW_IP"}/;
    print;
    ' yourpropertiesfile
    Make sure you change the file's protections so they are executable
    chmod +x nameof_yourscript
    There are other ways to do this, I just choose a perl script within a bash script. You could do it all with a bash script, you could use awk, you could use sed, you could use python, ruby, etc...

  • Using Sansung S3, not yet possible to share all the open tabs (using NFC) with another NFC phone. But only the one main tab I am currently browsing is possible.

    Using Sansung S3, Android 4.1.2, Firefox 24.0; not yet possible to share all the open tabs (using NFC) with another NFC phone. But only the one main tab I am currently browsing is possible to share. Is this the feature of current NFC feature of Firefox?
    If so, when will there be feature to share all the tabs?
    Thanks.

    I'm not sure if we will implement this. Sharing all the tabs you have open have many more security and privacy issues. Someone forgets that they had a tab open they did not want to share or miss-clicks on the share all option.
    We are looking into better ways to share tabs with devices that are nearby. Especially if they are on the same WiFi network.

  • How do I open a png file using firefox with windows 7

    In Windows XP I could save an image in the png format then open it using firefox, copy and paste it into an excel spreadsheet. However I can't do this in Windows 7. Has anybody else encountered this problem and found a solution?
    Kind regards

    Hi there,
    Could you describe your workflow and what happens? If you mean that double-clicking on a .png file in a normal folder (Explorer) window doesn't launch it in Firefox, which application is launched when you click it? If you want to make Firefox the default application to handle .png files, you need to change these settings in Windows 7. Unfortunately I don't have it myself (running a Mac here) so I don't remember the exact instructions. But I'm sure you could right-click on a .png file and select "Open With..." and from there manually pick Firefox. Try that and see if you get the results you want!
    Cheers,
    David

  • Applescript to print a .doc file using TextEdit with print dialog.

    I want to print a pdf file using TextEdit .
    I want to display the print dialog before doing the print operation.
    Can any one help me with apple scripts to perform this operation.
    We tried to use this script; but when I click Cancel on print dialog. I am getting an error saying "TextEdit got an error: Apple Event Handler failed".
    set printDoc to "Macintosh HD:Users:testuser:Testing:testprint.pdf"
    tell application "TextEdit"
    activate
    open printDoc
    print printDoc with print dialog
    quit saving no
    end tell
    Can anyone help me to fix this issue ?

    Clicking the cancel button in the print dialog is sending an error code back to the script. If you use a try statement you can handle it better. The script below will just ignore it. Or you could use an "on error" statement to do something else.
    set printDoc to "Macintosh HD:Users:testuser:Testing:testprint.pdf"
    tell application "TextEdit"
    activate
    open printDoc
    try
    print printDoc with print dialog
    end try
    quit saving no
    end tell
    Hope that helps. Though the plaintext of a pdf may be a little hard to read.

  • Can i print a file using thunderbird with command line switch

    Trying to automate printing task. I have a folder with 1000's and 1000's of eml files that need to be printed using thunderbird.
    I am able to get the command line switch to open the file in thunderbird.
    But what i really want is to print these files directly using thunderbird without opening the file in GUI.
    Thanks
    Dennison

    ส่งจาก จดหมายของ Windows
    จาก: Pat Willener
    ส่งเมื่อ: จ. 5 มกราคม 2558 6:15
    ถึง: thang dinhvan
    How can I print a file with mixed page orientation in windows 8.1?
    reply from Pat Willener in Adobe Reader Touch for Windows 8 - View the full discussion 
    I have a win 7 and a win 8.1 computer.  I have a file which contains both landscape and portrait pages.  The file prints correctly with the mixed orientation from the win 7 pc, but will only print with either landscape or portrait on the win 8.1 pc. 
    I am using Adobe reader XI on the win 7 pc and adobe touch on the win 8.1 pc
    If the reply above answers your question, please take a moment to mark this answer as correct by visiting: https://forums.adobe.com/message/7064031#7064031 and clicking ‘Correct’ below the answer
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:
    Please note that the Adobe Forums do not accept email attachments. If you want to embed an image in your message please visit the thread in the forum and click the camera icon: https://forums.adobe.com/message/7064031#7064031
    To unsubscribe from this thread, please visit the message page at , click "Following" at the top right, & "Stop Following"
    Start a new discussion in Adobe Reader Touch for Windows 8 by email or at Adobe Community
    For more information about maintaining your forum email notifications please go to https://forums.adobe.com/thread/1516624.

  • Can my Mac open or use a .lwp file?

    I've received an important file by email (using Mail) but it's a file with the extension ".lwp" and when I try to open it there seems to be no program on my Mac that can. Can anyone suggest a way to open or use this file?
    Many thanks

    iFelix posted whilst I was googling to answer this.
    A .lwp file was created in Lotus Word Pro see
    http://filext.com/detaillist.php?extdetail=lwp
    Having googled around the only to open the file you would need to run windows on your mac using virtual pc or if you have an intel mac you could use paralells deskltop.
    Then you could open the document using KeyView for lotus avaialbe for download here
    You could the copy paste the document into a regualar text editor then open it on OSX.
    Having said that it would be easier if you got the originator of the file to resend it in plain test or word etc.

  • How to get the file path of selected file using JFileChooser

    Hi All,
    I am trying to store the file on my FTP server after selecting the file from the user workstation using JFileChooser. But I am not able to write the file on FTP server or on user local machine where application is running. I am new to this FTP server coding. Can anyone help me in this.
    This is the code I wrote on button click user will able to select the file:
    String filename1;
    File file;
    JFileChooser fc = new JFileChooser();
    fc.showOpenDialog(this);
    file = fc.getSelectedFile();
    filename1 = file.getPath();
    txtFilePath.setText(filename1);
    Below is the code to write the file on my local machine first:
    BufferedWriter outFile = new BufferedWriter( fileName ) );
    outFile.write();
    outFile.flush( );
    outFile.close( );
    Any help will be greatly appriciated

    rp0428 wrote:
    >
    BufferedWriter outFile = new BufferedWriter( fileName ) );
    >
    There is NOTHING named 'fileName' in any of the code you posted so that code can't possibly compile let alone actually run.
    How can anyone help you if you won't post the actual code you are using?Its just a random snippet of other code that is totally irrelevant to this thread if you ask me.

  • LabWindows/CVI 2013 SP2 stops working when I try to open a file using the project file menu.

    I have windows 7 on my system and sometime late last year I starrted getting a Windows dialog telling me that LabWindows/CVI has stopped working when I try to open a file from the project file menu.  I also get an error when I run a project debug mode and use a selectFilePopup in the code.  The error says, "The program has suspended execution at address 0x75D5025E.  No source line information is available."  I've tried removing and reinstalling CVI to no avail.  Any suggestions?

    Constantin,
    Thank you for your response.  I've attached screnshots showing the version details for kernal32.dll and ntdll.dll.  I also looked at the updates to see which might have been installed when the problem started.  Unfortunately there are 15-20 updates every month.  I didn't take note of when the error started to occur.  At first it only affected my ability to open files from within the project (i.e. file->open->Source, etc).  Then I went back to modify a project that had a SelectFilePopup and found that that wouldn't work either. 
    Attachments:
    ntdll.dll version.jpg ‏15 KB

Maybe you are looking for