Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: JFileChooser Please Help

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JFileChooser Please Help

    Hi, I am fairly new to java. I was given an assignment to do which i find difficult. I must create a program that uses JFileChooser to select a zip file that contains 2 text files. The program then must manipulate data in the text files like reverse words and lines and save them as different files.

    So far i have created a JFileChooser object ( JFileChooser chooser = new JFileChooser(); ) but i don't know what to do next to tell it to open the zip file and look at the text documents. This is all new to me. I would really appreciate any help. Thanks alot in advance.


  2. #2
    Junior Member
    Join Date
    Oct 2011
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JFileChooser Please Help

    so far i have this.. i can select only zip files with the JFileChooser but i don't know how to get the program to deal with the data in the text files inside the zip file.
    //
    import javax.swing.*;
    import javax.swing.filechooser.FileNameExtensionFilter;
     
    public class Main {
     
    	public static void main(String args[]){
     
    		JFileChooser chooser = new JFileChooser();
    		FileNameExtensionFilter filter = new FileNameExtensionFilter("zip files","zip");
    		chooser.setFileFilter(filter);
    		chooser.showOpenDialog(null);
     
     
     
    	}
     
     
     
    }
    //
    Last edited by helloworld922; October 8th, 2011 at 09:20 PM.

  3. #3

  4. #4
    Junior Member
    Join Date
    Oct 2011
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JFileChooser Please Help

    Thanks alot. How do i get my JfileChooser object to to deal with the selected zip file?

  5. #5
    Member
    Join Date
    Sep 2011
    Posts
    32
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: JFileChooser Please Help

    Quote Originally Posted by mulligan252 View Post
    Thanks alot. How do i get my JfileChooser object to to deal with the selected zip file?
    The JFileChooser.getSelectedFile() will return the file selected by the user.

    java memory
    Last edited by namhm; December 4th, 2011 at 06:56 PM.

Similar Threads

  1. JFileChooser frustrations!
    By chrisivey1980 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: May 3rd, 2011, 05:32 AM
  2. JFileChooser setting directory
    By fox in forum AWT / Java Swing
    Replies: 2
    Last Post: February 18th, 2011, 11:58 AM
  3. Can't get it to save stuff with JFileChooser
    By javapenguin in forum What's Wrong With My Code?
    Replies: 35
    Last Post: August 11th, 2010, 04:13 AM
  4. Using JFileChooser to open and display an image
    By JavaN0ob in forum What's Wrong With My Code?
    Replies: 3
    Last Post: July 31st, 2010, 06:01 PM
  5. JFileChooser
    By FretDancer69 in forum AWT / Java Swing
    Replies: 2
    Last Post: February 3rd, 2010, 06:35 AM