Solved

File Manipulations

Posted on 2001-06-14
7
224 Views
Last Modified: 2010-03-31
Hi.

 I have a couple of related problems thats why am putting at one place

1: I want to make a file chooser that just choose the last folder in the tree structure
of the directories in which there are  files . ant not to allow the user to select the
files. that is just folder (directory) and not the files



2:

and now i have got the users folder path in which his/her java files are residing,  i want to know

>>> how to read all the files term by tem and do manipulation of any kind on each file.

what i have thought is to read the name and path of every file and put that all in
a vector but how to do it i dont know



kindly help me am in real trouble..................

 
     waiting for realy a kind reply.            
                                  nandini
0
Comment
Question by:nandini_kumar
7 Comments
 
LVL 9

Accepted Solution

by:
Ovi earned 100 total points
ID: 6190442
1. In the JFileChooser class you can specify the mode (only directories, only files, both) and filters.
2. Once you have a Directory selected, the file choodser will return to you an java.io.File object. In this File object, if is a directory you can call the method listFiles(), which will return to you an array of File objects. The rest depends on you (what you will do with the files).
0
 
LVL 3

Expert Comment

by:chrisos
ID: 6190473
Nandini,

1. Extend JFileChooser and call setFileFilter().  All you have to do is extend the javax.swing.filechooser.FileFilter abstract class to implement to just show File objects where isDirectory() returns true and listFiles does not return a 0 length array.

Then override aproveSelection so that folders you can accept have contents of the right type.

2. Call listFiles on the File returned and iterate through the File array that is returned, call getPath() which returns a string with the full path of the file.  Do an addElement to the Vector and thats that!

Regards,

Chrisos.
0
 
LVL 9

Expert Comment

by:Ovi
ID: 6190507
so what's new ?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 9

Expert Comment

by:Ovi
ID: 6190519
so what's new ?
0
 
LVL 3

Expert Comment

by:chrisos
ID: 6191075
Eh?
0
 

Expert Comment

by:teacher_mod
ID: 6198415
Hello nandini_kumar,

You have a number of old open questions with comments you have not responded to.  Would you please resolve those open questions before you ask the experts to provide you with additional free services.

teacher_mod
Community Support Moderator
Experts-Exchange
teacher_mod@experts-exchange.com
0
 

Expert Comment

by:SpideyMod
ID: 8289470
Force Accepted

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
eclipse argument 14 53
Basic Java Case or If-Else statement... 3 43
couple of eclipse 5 25
difference of if loops 23 42
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now