Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2007

Tip: Looking for answers? Try searching our database.

copying files from jar file to a filesystem

Thread view: 
craftereric@gmail.com - 27 Sep 2007 19:26 GMT
I have a jar file that contains directories and files. I need to copy
those directories and files to specified locations on a UNIX and
Windows file system.  So directory A in the jar will be copied to C:/
Temp on Windows and /tmp in Unix. Is there any sample code that will
get me started?  I guess I should use some sort of config file to
specify the source and destination directories.

The jar file has a structure like

A/
A/file1.txt
A/file2.txt

B/
B/file3.txt
B/file3.txt
Roedy Green - 27 Sep 2007 22:45 GMT
> So directory A in the jar will be copied to C:/
>Temp on Windows and /tmp in Unix. Is there any sample code that will
>get me started

look at the class com.mindprod.replicator.FetchZips

It downloads zips and unpacks them.

Source is available at http://mindprod.com/products1.html#REPLICATOR
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

craftereric@gmail.com - 27 Sep 2007 23:46 GMT
On Sep 27, 4:45 pm, Roedy Green <see_webs...@mindprod.com.invalid>
wrote:
> > So directory A in the jar will be copied to C:/
> >Temp on Windows and /tmp in Unix. Is there any sample code that will
[quoted text clipped - 8 lines]
> Roedy Green Canadian Mind Products
> The Java Glossaryhttp://mindprod.com

Thanks for the reply.  I looked at FetchZips but I don't think it will
meet my needs.  I could package my directories/files in a zip instead
of a jar but I need to be able to copy certain directories to one
location and other files to another location based on the file/
directory name.

Are there other things I can try?
craftereric@gmail.com - 27 Sep 2007 23:52 GMT
On Sep 27, 5:46 pm, craftere...@gmail.com wrote:
> On Sep 27, 4:45 pm, Roedy Green <see_webs...@mindprod.com.invalid>
> wrote:
[quoted text clipped - 19 lines]
>
> Are there other things I can try?

To expand on what I need the code to do:
For each directory or file in the archive, I need to process it. For
example, the file B/file3.txt would need to be copied to /var/tmp/
file.txt on a Unix machine and C:\Temp\LocalDir on a windows machine.
The entire directory A would need to be copied to /etc/ on Unix and C:
\Program Files\MyDir on Windows
Roedy Green - 28 Sep 2007 00:33 GMT
>For each directory or file in the archive, I need to process it.

Sounds like you need to read up on File.list and FilenameFilters.

See http://mindprod.com/jgloss/file.html

http://mindprod.com/jgloss/filter.html
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Hunter Gratzner - 28 Sep 2007 00:07 GMT
On Sep 28, 12:46 am, craftere...@gmail.com wrote:
> Thanks for the reply.  I looked at FetchZips but I don't think it will
> meet my needs.  I could package my directories/files in a zip instead
> of a jar

A jar is a zip.

> but I need to be able to copy certain directories to one
> location and other files to another location based on the file/
> directory name.

Write the code to do it. It is trivial.

> Are there other things I can try?

Read the API documentation.
Roedy Green - 28 Sep 2007 00:31 GMT
>Thanks for the reply.  I looked at FetchZips but I don't think it will
>meet my needs.  I could package my directories/files in a zip instead
[quoted text clipped - 3 lines]
>
>Are there other things I can try?

I did not intend for you to use FetchZips unmodified.  It was to show
you how to use the low-level zip manipulating tools.
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Roedy Green - 28 Sep 2007 01:19 GMT
>I did not intend for you to use FetchZips unmodified.  It was to show
>you how to use the low-level zip manipulating tools.

You can use the Zip methods to unpack jars.  Jars are just zips with a
few magic members.

see http://mindprod.com/jgloss/jar.html
http://mindprod.com/jgloss/zip.html
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.