User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 427,190 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,211 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 935 | Replies: 9
Reply
Join Date: Mar 2007
Posts: 45
Reputation: satish.paluvai is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
satish.paluvai satish.paluvai is offline Offline
Light Poster

plz help me in solving this files concept question

  #1  
Oct 14th, 2007
1)I need to compare two directories .if the files which r not same in the two directories i want to list them in a new text file
can anybody help me solving this question
2)how to write in a file in a String format using java?


satish.paluvai
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2007
Location: USA
Posts: 2,847
Reputation: Ezzaral is a name known to all Ezzaral is a name known to all Ezzaral is a name known to all Ezzaral is a name known to all Ezzaral is a name known to all Ezzaral is a name known to all 
Rep Power: 12
Solved Threads: 283
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Posting Maven

Re: plz help me in solving this files concept question

  #2  
Oct 14th, 2007
1.) Look at the API for File.
2.) Look at the API for BufferedWriter.
Reply With Quote  
Join Date: Nov 2004
Location: Netherlands
Posts: 5,752
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 18
Solved Threads: 199
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: plz help me in solving this files concept question

  #3  
Oct 14th, 2007
And define "not the same".
What are you going to use as criteria?
Names only? Sizes too? Or the actual content (and if that, how strict are you going to be? If they're 2 text files that differ only in whitespace, do you consider them the same or not?)?

Get your requirements straight before you even start thinking about putting something together.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote  
Join Date: Mar 2007
Posts: 45
Reputation: satish.paluvai is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
satish.paluvai satish.paluvai is offline Offline
Light Poster

Re: plz help me in solving this files concept question

  #4  
Oct 16th, 2007
Originally Posted by jwenting View Post
And define "not the same".
What are you going to use as criteria?
Names only? Sizes too? Or the actual content (and if that, how strict are you going to be? If they're 2 text files that differ only in whitespace, do you consider them the same or not?)?

Get your requirements straight before you even start thinking about putting something together.



yes I want to check two file have to be same in the name , size and also if the two directories have any sub directories and the files in the subdirectories those also it must be compared
Reply With Quote  
Join Date: Mar 2007
Posts: 45
Reputation: satish.paluvai is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
satish.paluvai satish.paluvai is offline Offline
Light Poster

how can we find out the size of a file or a directory using IO package in java

  #5  
Oct 17th, 2007
Originally Posted by satish.paluvai View Post
yes I want to check two file have to be same in the name , size and also if the two directories have any sub directories and the files in the subdirectories those also it must be compared


plz help me how can we find out the size of a file or a directory using IO package in java?
Reply With Quote  
Join Date: May 2007
Location: USA
Posts: 2,847
Reputation: Ezzaral is a name known to all Ezzaral is a name known to all Ezzaral is a name known to all Ezzaral is a name known to all Ezzaral is a name known to all Ezzaral is a name known to all 
Rep Power: 12
Solved Threads: 283
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Posting Maven

Re: how can we find out the size of a file or a directory using IO package in java

  #6  
Oct 17th, 2007
Originally Posted by satish.paluvai View Post
plz help me how can we find out the size of a file or a directory using IO package in java?

I've already told you: File has all of the methods you need. The length() method returns the length of the file in bytes. If the file is a directory, you will need to recursively sum up the length of the files in the that directory, which is obtained with the list() method.

If you had taken the time to look at the APIs that I suggested this should have been fairly straightforward.
Reply With Quote  
Join Date: Mar 2007
Posts: 45
Reputation: satish.paluvai is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
satish.paluvai satish.paluvai is offline Offline
Light Poster

Re: plz help me in solving this files concept question

  #7  
Oct 19th, 2007
ok,thanks for giving the clue
can we copy a file from one directory to another directory using java?
Reply With Quote  
Join Date: May 2007
Location: USA
Posts: 2,847
Reputation: Ezzaral is a name known to all Ezzaral is a name known to all Ezzaral is a name known to all Ezzaral is a name known to all Ezzaral is a name known to all Ezzaral is a name known to all 
Rep Power: 12
Solved Threads: 283
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Posting Maven

Re: plz help me in solving this files concept question

  #8  
Oct 19th, 2007
Originally Posted by satish.paluvai View Post
ok,thanks for giving the clue
can we copy a file from one directory to another directory using java?

Java does not have a native copy method. You must write your own short method for this using the IO classes. There are many implementations of copy available on the internet.
Reply With Quote  
Join Date: Mar 2007
Posts: 45
Reputation: satish.paluvai is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
satish.paluvai satish.paluvai is offline Offline
Light Poster

Re: plz help me in solving this files concept question

  #9  
Oct 20th, 2007
can u just suggest one idea (for copying the files from one directory to another)
Reply With Quote  
Join Date: Feb 2006
Posts: 1,460
Reputation: masijade is just really nice masijade is just really nice masijade is just really nice masijade is just really nice masijade is just really nice 
Rep Power: 9
Solved Threads: 131
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Virtuoso

Re: plz help me in solving this files concept question

  #10  
Oct 20th, 2007
Read the API for FileChannel. The source and destination directory does not make any difference whatsoever, as you are always dealing with two file (or file channel) objects. Where they are makes no difference (to a point). Stop focusing on this system and/or procedural type stuff.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Java Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 10:07 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC