Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

File Manipulations

Posted on 2001-06-14
7
Medium Priority
?
258 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 9

Accepted Solution

by:
Ovi earned 300 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.
Suggested Courses

610 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