Solved

File Manipulations

Posted on 2001-06-14
7
244 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 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
Independent Software Vendors: 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!

 
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

Independent Software Vendors: 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 Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn different types of Android Layout and some basics of an Android App.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

724 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