Anyone got a zip-tip?

When I try to Zip a file(backup.zip) everything is good except one thing.
When I use WinZip to unzip the file, the path for the file contains all subdirectories eg. c:\mycatalog\backup\db\data.data
I would like the path to be like: db\data.data
The code:
pathName is "c:\mycatalog"
fileName is "backup"
public class Zip {
private static ZipOutputStream zos;
* Creates a Zip archive. If the name of the file passed in is a
* directory, the directory's contents will be made into a Zip file.
public static void makeZip(File pathName, String fileName)
throws IOException, FileNotFoundException
File file = new File(pathName,fileName);
zos = new ZipOutputStream(new FileOutputStream(pathName.toString()+"\\"+fileName+".lum"));
//Call recursion.
recurseFiles(file);
//We are done adding entries to the zip archive,
//so close the Zip output stream.
zos.close();
* Recurses down a directory and its subdirectories to look for
* files to add to the Zip. If the current file being looked at
* is not a directory, the method adds it to the Zip file.
private static void recurseFiles(File file)
throws IOException, FileNotFoundException
if (file.isDirectory()) {
//Create an array with all of the files and subdirectories
//of the current directory.
String[] fileNames = file.list();
if (fileNames != null) {
//Recursively add each array entry to make sure that we get
//subdirectories as well as normal files in the directory.
for (int i=0; i<fileNames.length; i++) {
recurseFiles(new File(file, fileNames));
//Otherwise, a file so add it as an entry to the Zip file.
else {
byte[] buf = new byte[1024];
int len;
//Create a new Zip entry with the file's name.
ZipEntry zipEntry = new ZipEntry(file.toString());
//Create a buffered input stream out of the file
//we're trying to add into the Zip archive.
FileInputStream fin = new FileInputStream(file);
BufferedInputStream in = new BufferedInputStream(fin);
zos.putNextEntry(zipEntry);
//Read bytes from the file and write into the Zip archive.
while ((len = in.read(buf)) >= 0) {
zos.write(buf, 0, len);
//Close the input stream.
in.close();
//Close this entry in the Zip stream.
zos.closeEntry();

http://forum.java.sun.com/thread.jsp?forum=31&thread=408815
Found with
http://search.java.sun.com/search/java/index.jsp?qp=&nh=10&qt=%2Bzip%2C+%2B%22relative+path%22&col=javaforums

Similar Messages

  • I have question about hooking up an external hdd to a time capsule and still have my printer hooked up as well. Anyone got any tips for me, how to do it and what brand of harddrive that will work best for me 1 or 2 TB

    i have question about hooking up an external hdd to a time capsule and still have my printer hooked up as well. Anyone got any tips for me, how to do it and what brand of harddrive that will work best for me 1 or 2 TB

    You just need a powered hub.. if you already use one then fine.
    Plug in just about any external hard disk will work fine. Format has to be readable by the TC.. ie fat32.. or much better HFS+.. plug it into a Mac to prepare the drive.
    Pick whatever size suits.. nowadays 2TB are most economical.
    WD, Seagate have goobled up all the minor players.. so pick one.
    Whatever suits your budget and asthetics.
    NOTE.. The USB on the TC is fine for printers.. IMHO it is the wrong way to go with USB disks.. use the internal disk of the TC.. USB is less than half the native speed plugged into a Mac.. TC to USB is slow.. far slower than internal drive.. or using external drive as external.

  • I recently bought a Samsung Galaxy s5 and cannot receive iMessages from iphones, I have deleted my apple id, turned off imessage, turned off spam messages on my android device, wasted 35 minutes on the phone to Apple's 'Support' has anyone got any tips?

    I recently bought a Samsung Galaxy s5 and cannot receive iMessages from iphones, I have deleted my apple id, turned off imessage, turned off spam messages on my android device, wasted 35 minutes on the phone to Apple's 'Support' has anyone got any tips?

    Hi,
    Do you mean you are not getting SMS text messages now ?
    If so start here
    Follow the Account management options until you are offered and email contact.
    Explain the issue via email as only someone in Support can now remove your iPhone Number from iMessages if it has not "de-registered" itself correctly.
    8:28 pm      Wednesday; May 7, 2014
    ​  iMac 2.5Ghz i5 2011 (Mavericks 10.9)
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb (Snow Leopard 10.6.8)
     Mac OS X (10.6.8),
     Couple of iPhones and an iPad

  • Anyone got 8.1.6 to work on Slackware 7?

    It seems to fail on the DB configuration
    assistant which locks up (after spawning
    off loads of threads looking at the process
    listing). A friend of mine who installed
    8.1.6 on Redhat 6.2 had no probs.
    Anyone got any suggestions?

    May be you need to make soft link for the following files
    ln -s /usr/bin/awk /bin/awk
    ln -s /bin/free /usr/bin/free
    then will be able to get through the installation.
    Afterward, you may encounter problem on using dbstart to startup you db, it is due to the script is not able to capture the version number of the installed oracle.
    you may just edit the create another script by copying the origin dbstart, and add a statement, VERSION="8.1", near somewhere STATUS=1. Hopefully, you can have this up and running by these few tips.
    null

  • Ios 8 keeps crashing on my iPad 2. Has anyone got a solution to this. My iPad 2 was great before upgrading.

    ios 8 keeps crashing on my iPad 2. Has anyone got a solution to this. My iPad 2 was great before upgrading. It's so bad that now I want to throw my iPad out so if anyone has tips to enhance my iPads performance please share.

    I would read up on restoring your device
    Restore
    http://support.apple.com/kb/HT1414
    Especially if you installed the update over the air,  a restore, which will use a computer to install the iOS again sometimes helps. There seems to be better results from doing it via iTunes than over the air

  • Has anyone got iFS working in Tomcat ?

    iFS 1.1.9
    We have a urgent need to get iFS running in a Servlet 2.2 container and OC4J does not support iFS yet. I know this is not supported but has anyone got iFS working in Tomcat ? If so, pls do me a BIG favour by letting me have your config files, such as
    - server.xml
    - <tomcat home>\conf\web.xml
    - web.xml for the tomcat context)
    - wrapper.properties (if you are using tomcat as an NT service)
    - tomcat-apache.conf (or equivalent)
    - <oracle home>/apache/apache/conf/httd.conf
    - A listing of relevant environment variables (by doing a "set>env.lis" or similar)
    - and any other files you might think is relevant
    Thanks a million in advance.
    null

    iFS 1.1.9 / Oracle 8.1.7 / Tomcat 4.0.1 / Windows 2000
    After several hours of fiddling around with the configuration
    files, I finally got the iFS up and running on my test machine.
    Briefly here's what I did:
    1) create application directories
    <tomcat_home>/ifs/files/WEB-INF/classes
    <tomcat_home>/ifs/files/WEB-INF/lib
    2) Add the following to <tomcat_home>/conf/server.xml:
    <Context path="/ifs/files" docBase="ifs/files"
    debug="0" reloadable="true">
    <!-- got this from jserv.properties -->
    <Environment name="ORACLE_HOME" type="java.lang.String"
    value="oracle_home"/>
    <Environment name="ORACLE_SID" type="java.lang.String"
    value="sid"/>
    <Environment name="LD_LIBRARY_PATH" type="java.lang.String"
    value="oracle_home/lib:oracle_home/ctx/lib"/>
    <Environment name="NLS_LANG" type="java.lang.String"
    value=".UTF8"/>
    </Context>
    Please replace oracle_home with your installation directory and
    fill in your SID as well.
    3) create <tomcat_home>/<tomcat_home>/ifs/files/WEB-INF/web.xml
    with the following definitions:
    <servlet>
    <servlet-name>oracle-jsp</servlet-name>
    <servlet-class>oracle.jsp.JspServlet</servlet-class>
    <init-param>
    <param-name>logVerbosityLevel</param-name>
    <param-value>WARNING</param-value>
    </init-param>
    </servlet>
    <servlet>
    <servlet-name>oracle-ifs-servlet</servlet-name>
    <servlet-
    class>oracle.ifs.protocols.dav.impl.IfsDavServlet</servlet-class>
    <init-param>
    <param-name>classpath</param-name>
    <!-- this classpath is crucial for JSP compilation.
    | The value has to be in one single line without
    | linebreaks and spaces !!!
    -->
    <param-value>
    tomcat_home/webapps/ifs/files/WEB-INF/lib/ojsp.jar;
    tomcat_home/webapps/ifs/files/WEB-INF/lib/webui.jar;
    tomcat_home/webapps/ifs/files/WEB-INF/lib/adk.jar;
    tomcat_home/webapps/ifs/files/WEB-INF/lib/http.jar;
    tomcat_home/webapps/ifs/files/WEB-INF/lib/repos.jar;
    tomcat_home/webapps/ifs/files/WEB-INF/lib/email.jar;
    tomcat_home/webapps/ifs/files/WEB-
    INF/lib/release.jar;
    tomcat_home/webapps/ifs/files/WEB-INF/lib/utils.jar;
    tomcat_home/webapps/ifs/files/WEB-
    INF/lib/settings.jar;
    tomcat_home/webapps/ifs/files/WEB-INF/classes;
    tomcat_home/lib/xmlparserv2.jar;
    tomcat_home/lib/classes12.jar;
    tomcat_home/common/lib/servlet.jar;
    </param-value>
    </init-param>
    <init-param>
    <param-name>ifs.dav.servicepassword</param-name>
    <param-value>manager</param-value>
    </init-param>
    <init-param>
    <param-name>encode_to_java</param-name>
    <param-value>true</param-value>
    </init-param>
    <init-param>
    <param-name>page_provider</param-name>
    <param-
    value>oracle.ifs.protocols.dav.impl.jsp.IfsJspResourceProvider</p
    aram-value>
    </init-param>
    <init-param>
    <param-name>page_repository_root</param-name>
    <param-value>ifs_home/ifsjsps</param-value>
    </init-param>
    <init-param>
    <param-name>unsafe_reload</param-name>
    <param-value>false</param-value>
    </init-param>
    <init-param>
    <param-name>developer_mode</param-name>
    <param-value>true</param-value>
    </init-param>
    </servlet>
    <servlet-mapping>
    <servlet-name>oracle-ifs-servlet</servlet-name>
    <url-pattern>/*</url-pattern>
    </servlet-mapping>
    <!-- The mapping for the JSP servlet -->
    <servlet-mapping>
    <servlet-name>oracle-jsp</servlet-name>
    <url-pattern>*.jsp</url-pattern>
    </servlet-mapping>
    tomcat_home and ifs_home must be replaced with your installation
    directories.
    4) Copy the iFS and Oracle JARs to the locations specified in
    web.xml
    You may choose either the applications lib directory or the more
    general tomcat_home/lib for that purpose.
    One hint on libraries: Tomcat will ignore ZIP files, you have to
    use JAR. I renamed Oracle's classes12.zip to classes12.jar for
    that reason.
    5) Create settings.jar
    This was the most tricky part. I packed everything under
    ifs_home/settings into the file settings.zip, renamed this to
    settings.jar and moved it to the WEB-INF/lib directory. Seems a
    bit of a kludge to me, anyone with a better solution is welcome.
    6) Start tomcat
    7) try http://yourtomcathost:8080/ifs/files/index.html
    You should see the ifs login screen then.
    One word about the application environment. In this
    configuration every user class has to go into
    <tomcat_home>/ifs/files/WEB-INF/classes, the
    ifs_home/user_classes is of no use here. And don't try to set
    the classpath within catalina.bat, tomcat will completely ignore
    this setting.
    Finally, I know that this environment is not supported but as
    long as the iFS servlet meets the standards, every standard
    compliant servlet engine should do the job.
    Good luck

  • Has anyone got Robin Thick iTunes single!!!??

    Has anyone got his single with Pharell? I really want this single bad but because I am in the uk I cannot download
    Can anyone help? or tips on how I can get it?? If you can I will be forever in you debt!!!
    Thanks
    Nick

    Hi,
    Did you purchase song from iTunes Store? If so, have you tried deleting song from your library and redownloading from purchased in iTunes Store?
    Jim

  • I have got a zip file "tar.bz" how to install firefox from it

    Hi!
    I am using an older version of firefox , so i downloaded the latest version for linux.
    I got a zip file "firefox-4.0.tar.bz2". But i don't know how to install it.
    can anyone please say me the way to install it.
    and after installing will the plugins that i use from my previous version will be there in this new version by default or again do i need to install them?
    thanking you,
    smile

    See:
    *http://kb.mozillazine.org/Installing_Firefox#Linux

  • Hello,  I have a strange file in my Users folder, named PortDetect.log I have no idea which app created it and it reappears when I delete it.  Has anyone got the same file? Or know where it may originate from?  Thanks in advance!

    Hello,
    I have a strange file in my Users folder, named PortDetect.log
    I have no idea which app created it and it reappears when I delete it.
    Has anyone got the same file? Or know where it may originate from?
    Thanks in advance!

    know where it may originate from?
    The Huawei wireless modem driver.

  • I have an ipod touch 5th gen and when connected to itunes i get a message saying itunes was unable to load data class information from sync services. reconnect or try again later. anyone got any ideas? i've tried most things on most forums but still no jo

    i have an ipod touch 5th gen and when connected to itunes i get a message saying itunes was unable to load data class information from sync services. reconnect or try again later. anyone got any ideas? i've tried most things on most forums but still no joy

    Try here:
    iTunes for Windows: "Unable to load data class" or "Unable to load provider data" sync services alert
    If not successful see the previous discussion on the right side of this page with the green checkmark.

  • TS1538 I cannot get Itunes to recognize my Iphone 4s, or Ipad2 after installing IOS7???  Says must install Itunes 11.1.  0So I did and still no luck.  Anyone got any advice???

    I cannot get Itunes to recognize my Iphone4s, or Ipad 2 after installing IOS7?  Says must install Itunes 11.1 So I did that and still no luck.  Anyone got any advice???

    Version 11.1.5.5 of iTunes was just released today. If you update to that, does that help with the recognition troubles?
    http://www.apple.com/itunes/download/

  • My Time Capsule expired and no longer works. My printer (a HP) will now not work as it still wishes to connect through the Time Capsule. It will not allow itself be recognised through a USB connection to my Mac. Anyone got any ideas?

    My Time Capsule expired and no longer works. My printer (a HP) will now not work as it still wishes to connect through the Time Capsule. It will not allow itself be recognised through a USB connection to my Mac. Anyone got any ideas?

    You will need to install the printer on your Mac
    Open System Preferences (gear icon) on the dock
    Open Print & Fax
    Click the + (plus) button at the bottom of the printer list
    Wait for your printer to appear in the next box, then click it to highlight it
    Click Add at the lower right
    Be sure to select the correct printer when you try to print as you will see your printer listed twice. Good idea to make the printer now installed on your Mac the default printer so you do not have to choose which printer to use each time you want to print.
    You can also go into Print & Fax, select the printer associated with the Time Capsule and click the - (minus) button if you want to delete that location.

  • I used to send photos from my Lumix Tz-40 camera directly to my iPad using the cameras WIFI. Since I installed IOS7 the connection no longer works. Anyone got any ideas. I have already installed the latest version of Panasonic's Image App (1.7.1)

    I used to send photos from my Lumix Tz-40 camera directly to my iPad using the camera's WIFI. It was all working well until I installed IOS7.  The connection no longer works. The camera still keeps the iPad in its connection history. The camera's wifi network still appears when I select a WiFi network from the iPad but the Wifi status icon never appears on the iPad. So the connection is never made.
    Anyone got any ideas. I have already installed the latest version of Panasonic's Image App (1.7.1)

    Hi there,
    You're running an old version of Safari. Before troubleshooting, try updating it to the latest version: 6.0. You can do this by clicking the Apple logo in the top left, then clicking Software update.
    You can also update to the latest version of OS X, 10.8 Mountain Lion, from the Mac App Store for $19.99, which will automatically install Safari 6 as well, but this isn't essential, only reccomended.
    Thanks, let me know if the update helps,
    Nathan

  • Formatting lost in the text file, got after zipping.

    Hello ABAP gurus,
    A text file has to be zipped .I have used the class method CL_ABAP_ZIP-SAVE() to create a zip file in the application server.    The zip file is double clicked and the text file is opened.
    The formatting is lost in the text file, got after zipping.
    Please let me know how I maintain the formatting in the zip file.
    Thanks.
    Edited by: GVVisweswara . on May 5, 2011 5:17 PM

    Hi.,
    Check this link: [Zip text file using Cl Zip|http://www.saptutor.org/?p=59]
    also this wiki., http://wiki.sdn.sap.com/wiki/display/ABAP/CL_ABAP_ZIPusage-ZippingABAPreportoutput
    hope this helps u.,
    Thanks & Regards
    Kiran

  • Has anyone got the QT stand alone installer to work?

    OK, Has anyone got the QT stand alone installer to work that has a problem getting IT6 to work also?
    You can look at my original thread and see what I've been through: http://discussions.apple.com/thread.jspa?threadID=262511&tstart=0
    and now am stuck with an old version of QT and no version of IT! Can't update iPod, can't do crap. How slow can Apple be to fixing whatever bug is in IT6?! It's obvious that alot of people are having trouble and many of us are having the exact same or similar problems. Apparently a call to support is no help.
    Mark

    I didget QT stand alone to install. I had the error -3 message. I unistalled itunes and quicktime. Then I reinstalled using my orginal ipod disc. I then was asked to upgrade to ipod 6 or something. Which I did. Still got the error -3. Then I got the QT stand alone to install by it self and every thing works great now. There was some thing stating if I wanted to "Unistall QT for windows" I said yes. There were some error associated with removing "QT for Windows" during the install but after that it works great. It took something like 20 min. for it to download when it took itunes only 7 min. to download earlier.

Maybe you are looking for

  • With windows xp.

    I just got the iphone 4s. I want to use icloud. However i have a pc with windows xp. Apple says that i nead windows7 or vista. I can't easily upgrade. Is there a workaround for Windows XP?

  • The email address for iCloud for me is no longer in use. I need to change my email and password on my iPad.

    On my iPad it will not let me change my email address. The old one is no longer in use and I cannot get emails on it any longer. How do I change iCloud email address on the iPad?

  • Ejbc error

    Hi! I have a stateless session bean with multiple interfaces. When I try to deploy the bean, I get the following error message: Cannot deploy the component Deployment Error -- Error while running ejbc -- Fatal Error from EJB Compiler -- -- Compilatio

  • Yes Im a newbie - Why cant I stack? Grrrr

    Ok I am embracing the help manual - stroking it gently and still having an issue. I made a catalog from my shoot - 785 images of a four group family shoot. I made collections to organize the different locations we shot the groups at. Now I want to st

  • WIndows Enterprise 8.1 - MDT 2013

    Hi All I'm using MDT2013 and ADK 8.1. I am trying to create a new Windows 8.1 ent build and am having a few strange issues... I have created a standard TS for the initial build, when I deploy the TS everything works as expected except the build doesn