How to select  file and directories to ZIP

HI,
I'm doing an application that would zip a file and directories. here's an exmple:
fileName = FileNameTest.csv
folderName = FileNameTest_A
folderName = FileNameTest_B
The foldername is taken from the fileName with "_A" and "_B" at the end. The file and directories are located in a directory where there can also be other files and directories in it. What I want to do is to zip only the above file and directories.
Any help will be greatly appreciated!
Thanks!

Not a very clear specification. What do you want the resulting zip entries/files/paths to look like?

Similar Messages

  • How to FTP file and extract the zip file automatically?

    Hi,
    My app needs to FTP another site and also automatically unzip the transferred file over the internet by user clicking on one button. Any experts? thanks.

    How do you open a can of beans before you take it out of the pantry?
    However I suppose your question only sounded stupid like that, you didn't really mean it that way. One problem is that you didn't mention which way the transfer was going. I assume you are asking about getting a file and unzipping it? Many of the FTP clients described in the article that jmennen referred to allow you to get an InputStream that allows you to read bytes from the server. You would take this InputStream and wrap it in a ZipInputStream. That way you could unzip the file as you transfer it from the server, rather than having to use a temporary file between the two steps.
    But if you really meant that you wanted the unzipping to take place on the server before you did the download, no, you can't do that.

  • JFileChooser - show files and directories only select directory

    I need a JFileChooser that will display directories and zip files but only allow a directory to be selected.
    basically i need to be able to select a certain directory that contains a certain zip file, so to make it easier to find i want the zip files to show up so i can find the correct directory...
    I tried...
            JFileChooser jfc = new JFileChooser();
            jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            jfc.setFileFilter(new FileFilter() {
                public boolean accept(File f) {
                    if (f.isDirectory()) {
                        return true;
                    else if (f.getName().endsWith(".zip")) {
                        return true;
                    return false;
                public String getDescription() {
                    return "testing";
            });but that only displays directories in the GUI.
    The javadoc for the setFileSelectionMode() says, "Sets the JFileChooser to allow the user to just select files, just select directories, or select both files and directories. The default is JFilesChooser.FILES_ONLY. " ....which makes you think that setting the file selection mode only alters what can be SELECTED...however it alters what is displayed as well.
    ...any ideas?
    thanks

    This should display the files of interest provided the filter is tuned to do so, and allow you to select either the file of interest or the folder... If you select the file, then folder it is contained is returned.
    JFileChooser chooser = new JFileChooser();
    chooser.setCurrentDirectory(new java.io.File("."));
    MyFileFilter filter = new MyFileFilter();
    chooser.setFileFilter(filter);
    chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    int returnVal = chooser.showOpenDialog(this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {              
      System.out.println(chooser.getCurrentDirectory());
    }

  • I have an external hard drive that was formatted by a PC and has files and directories etc. I want to format it and use it on my IMAC for backup but I can't seem to write to it nor can I delete current content. How do I initialize it for use with the MAC?

    I have an external hard drive that was formatted by a PC and has files and directories copied to it etc. I want to use it on my IMAC for backup. I see it on my my IMAC . I can open files etc.  But I can't seem to write to it nor can I delete current content. I don't care if I lose current content. How do I initialize it for use with the MAC?

    You can't write to it because it's formatted as NTFS which OS X will read but not write to. If you want to continue using the drive with both a PC and OS X you will need to download and install NTFS-3G so you can then write to it from your Mac. You can get NTFS-3G at:
    http://www.macupdate.com/app/mac/24481/ntfs-3g
    If you want to use the drive exclusively with your Mac then move the data off it and reformat it in Disk Utility (Applications - Utilities - Disk Utilities) as Mac OS Extended (Journaled.)

  • How to bundle all files and directories in a package?

    how to bundle all files and directories in a package?
    i plan to put all image files, .class files and some other files together.and then double click the package to execute the program.
    should i use jar?is there a link for tutorial or example?
    thanks in advance

    http://java.sun.com/docs/books/tutorial/jar/

  • Managing files and directories

    I have a palm tx and am lost on how to transfer files back and forth between pc and palm. The syncing process seems to work for the applications but I would like to select files and transfer them to the palm and be able to create directories and manipulate files on the palm. How is this done?
    Post relates to: Palm TX

    johhfin wrote:
    I am trying to install doom(game) to the palm. The instructions are below and mention to bring a file or two over using hotsync. Seems that hotsync on my palm is automated, ie when I push the button on the usb is just downloads preset items. Is there a way I can hotsync just one file to a certain location?
    1/ install zdoomz.prc to your device
    2/ at first launch, it will create the needed directory (/PALM/Programs/ZDoomZ) & register
    the .zdk extension for itself.
    The link between .zdk files & /PALM/Programs/ZDoomZ is LOST after each reset & if another
    software register it -zquake, zhexen, ...-
    Run the launcher each time before a hotsync of a zdk file to be sure it goes in the right folder
    3/ copy "zdoomz.zdk" in the previous folder /PALM/Programs/ZDoomZ, or hotsync it.
    4/ copy your WAD file in the /PALM/Programs/ZDoomZ
     using either a smart card reader or the "mp3" trick => check http://www.zodiacgamer.com
     forum for more details.
    5/ if you want sound, install the gus patches in /PALM/Programs/Timidity
     The instructions are pretty clear (to me), but I question #3 about HotSyncing the .zdk file.  Just copy it as instructed.  The only file going to RAM is the .prc file, all the rest go to the SD card.
    I would HotSync the zdoomz.prc file only (to the device), then after it creates all the folders mentioned (on the SD card) use a cheap card reader to install all the other files directly to your SD card. (Remove it from the TX)  Once reinserted, run the ZDoomZ program file.
    Now whether you can get a decent copy of Doom to run on a Palm device is another story... Are you putting this on a Zodiac or your TX?
    WyreNut
    Message Edited by WyreNut on 08-27-2009 06:40 AM
    I am a Volunteer here, not employed by HP.
    You too can become an HP Expert! Details HERE!
    If my post has helped you, click the Kudos Thumbs up!
    If it solved your issue, Click the "Accept as Solution" button so others can benefit from the question you asked!

  • Copying files and directories from AIX/UNIX to Client PC in ABAP.

    Hi all,
    Can someone help me. I have to make an ABAP program which copies the J2EE Visual Adminstrator programs from our AIX/UNIX server to the Client PC.
    I have to copy all files and directories in /usr/sap/DXI/DVEBMGS70/j2ee/admin/.  to  D:\j2ee\*.*
    Is it possibly in ABAP? How would you do it?
    Best regards
    Brian Strunge

    Hi,
    try this.
    DATA: lcl_directory TYPE char128,
    constants: c_mask TYPE char9 VALUE ',.,..'.
    lcl_directory = ''/local/data/interface/A28/DM/OUT'. <b>"target directory</b>
    CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
    EXPORTING
    directory = lcl_directory
    filemask = c_mask
    IMPORTING
    serverfile = p_f2
    EXCEPTIONS
    canceled_by_user = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    MESSAGE e000(zmm) WITH text-039.
    flg_app = 'X'.
    ENDIF.
    ******************************************************8
    REPORT zdirtest.
    DATA lv_dir TYPE rsmrgstr-path VALUE '/usr/sap/trans/data'. <b>"source directory</b>
    DATA: wa_files TYPE rsfillst,
    it_files LIKE TABLE OF wa_files.
    START-OF-SELECTION.
    CALL FUNCTION 'SUBST_GET_FILE_LIST'
    EXPORTING
    dirname = lv_dir
    filenm = '*'
    TABLES
    file_list = it_files
    EXCEPTIONS
    access_error = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    WRITE /1 'Error! :-('.
    ELSE.
    LOOP AT it_files INTO wa_files.
    WRITE: /1 wa_files-name,
    wa_files-len.
    ENDLOOP.
    Regards
    Anver

  • Traversing files and directories underneath a directory

    I'm looking at some sample code about traversing files and directories underneath a directory. I'm trying to understand exactly what the code is doing. I see that dir.list() is building a string array of filenames and directory names. Then it tests each to see whether it's a directory. If it's a directory then is looks and each file and or directory in that directory.
    But I don't understand how it keeps going below just the second level directory. The two lines of code I'm not sure I understand are:
    1) process(dir);
    2) visitAllDirsAndFiles(new File(dir, children));
    Can anyone help me to understand exactly how this code block can traverse beyond just the second directory level?
    // Process all files and directories under dir
        public static void visitAllDirsAndFiles(File dir) {
            process(dir);
            if (dir.isDirectory()) {
                String[] children = dir.list();
                for (int i=0; i<children.length; i++) {
                    visitAllDirsAndFiles(new File(dir, children));

    No, I guess they might be assuming somethings. Here is the page with the sample code:
    [http://exampledepot.com/egs/java.io/TraverseTree.html]

  • Listing Files and Directories

    On our internal web page we have some links to various areas
    like Office Forms, Safety, etc... The supervisors that maintain
    these documents have access to shares that allow them add, remove,
    and update the files as needed. Since the content in each changes
    fairly often we're currently using CFDIRECTORY with the LIST action
    to display the contents to the users on the web page.
    Some of the areas now contain quite a few documents and the
    supervisors would like to be able to group their documents in
    subdirectories. I know I can I can use RECURSE="yes" to have the
    web page list the contents of these folders, but the supervisors
    would like the end users to see the subdirectories as well so
    things are less confusing and cluttered on both ends.
    So is there any way in CF to set up these pages so that
    subdirectories can can be navigated and the documents selected? If
    possible, I'd like something that can handle this dynamically so
    that I don't have to constantly change the code every time a
    supervisor decides to add/remove a directory.
    We're currently running CF8 Standard.
    Thanks!

    Vidikron wrote:
    > On our internal web page we have some links to various
    areas like Office Forms,
    > Safety, etc... The supervisors that maintain these
    documents have access to
    > shares that allow them add, remove, and update the files
    as needed. Since the
    > content in each changes fairly often we're currently
    using CFDIRECTORY with the
    > LIST action to display the contents to the users on the
    web page.
    >
    > Some of the areas now contain quite a few documents and
    the supervisors would
    > like to be able to group their documents in
    subdirectories. I know I can I can
    > use RECURSE="yes" to have the web page list the contents
    of these folders, but
    > the supervisors would like the end users to see the
    subdirectories as well so
    > things are less confusing and cluttered on both ends.
    >
    > So is there any way in CF to set up these pages so that
    subdirectories can can
    > be navigated and the documents selected? If possible,
    I'd like something that
    > can handle this dynamically so that I don't have to
    constantly change the code
    > every time a supervisor decides to add/remove a
    directory.
    >
    > We're currently running CF8 Standard.
    >
    > Thanks!
    >
    Pretty much what you got should do it. The simplest change
    would be to
    output entire directory structure on your current page, just
    nesting the
    files and directories.
    I would just create a looping output that uses the fields of
    the record
    set to output the directories and the files with-in them
    probably as a
    nested set of <ul> unordered lists.
    If you want to break up this user interface into distinct
    units which
    only list the contents of a current directory then just do
    the output as
    you have it without using recursion. But make the
    sub-directory
    listings links that when clicked repopulate the current page
    listing the
    contents of the selected directory.
    Neither should take a great deal of rework to your current
    interface.

  • [Solved] File browser that supports mixed files and directories

    Are there any file browsers that show files and directories together, in the way that macs do? Most of the time I like the seperated structure, but for some things I'd like to be able to sort by, say, date modified, and have all the newest files and directories together. I'm hoping I'm just overlooking an option somewhere (I'm using nemo now), but this is kind of a tricky thing to google.
    EDIT
    Just looked again and noticed the option, right there in front of me. Oops. Still, andyone happen to know how to make this a property of a single directory, and not global?
    Last edited by ce1984 (2014-04-25 02:05:16)

    ls - just don't use
    --group-directories-first

  • [SOLVED] Check for old configuration files and directories in ~/

    Hello,
    Since I started with Arch I tried and uninstalled a few programs and would like to check for possible left overs in ~/
    I tried the "lostfiles" script, but it does not seem to check the home directory. Then I followed this: https://wiki.archlinux.org/index.php/Pa … ny_package - But using the suggested alias in my bash, it gives me the below:
    $ pacman-disowned-files
    [sudo] password for [my user]:
    bash: -path: command not found
    bash: /root: Is a directory
    bash: -print: command not found
    What am I doing wrong?
    Regards
    Martin
    Last edited by onslow77 (2015-02-04 23:52:44)

    Hello,
    ohh, I see, I need to do this (in directory where I put the script)
    sh pacman-disowned -files > test.txt
    That solved the usage of the commands, but it does not however list files [in the test.txt file] that do not belong to any package in my ~/ directory (I put a dummy file in my ~/ to see if it got noticed) - but it did not. So how can I list files and directories in my ~/ directory that is not put there by any package that currently is installed?
    Regards
    Martin
    Last edited by onslow77 (2015-02-04 22:49:11)

  • Please help on create files and directories in Session Bean

    Hi,
    I am trying to create files and directories at run time from a session bean. Since EJB 2.0 prohibit the use of the java.io.* package. The only thing that I know how is to use the URLConnection. After getting a connection through URL. I may use the getOutputStream() to get a output stream to write to the HTTP server. But the getOutputStream() returns an OutputStream object which is one of the package in the java.io package. Since I need to create file and directory, I need to use the FileOutputStream that is also under the java.io package.
    Can someone give me a hint what should I do. Here is a directory and the file that I may need to create;
    Directory1/Drictory2/myFiles.au
    Thank you in advance, your help is greatly appreciated.

    From 24.1.2 (Programming Restrictions) of the EJB 2.0 spec:
    � An enterprise bean must not use the java.io package to attempt to access files and directories in the file system.
    The file system APIs are not well-suited for business components to access data. Business components should use a resource manager API, such as JDBC, to store data.
    You might want to look at the File System Service Provider in JNDI for an alternative approach. I have never used an FSSP though.

  • Set numerous files and directories to 664 and 775

    This is actually a Solaris 9 question:
    I need to set numerous files/directories under a selected "branch" (directory) to 664 (files) and 775 (directories), recursively.
    also need to ensure all files/directories created from then on are 664/775, respectively.
    Thanks

    I guess I wasn't clear...
    The directory/file structure consists of multiple levels (subdirectories) and files in each of those subdirectories.
    I can do a
    chmod -R 775 whatever
    this changes ALL files AND directories under directory: whatever to 755
    I need to change all subdirectories to 775 and all files (non-directories) within those subdirectories to 664
    Is there a way to indicate file or directory.. There does not appear to be an option using chmod..
    Thanks

  • File Chooser is displaying names of the Files and Directories as boxes

    Hi All,
    Actually i am working on an application in which i have the requirement to internationalize the File Chooser in All Operating Systems. The application is working properly for all languages on MAC OS, but not working properly for the language Telugu on both the Ubuntu and Windows OS. The main problem is, when i try to open the File Chooser after setting the language to TELUGU all the labels and buttons in the File Chooser are properly internationalized but names of Files and directories in the File Chooser are displaying as boxes.
    So please provide your suggestions to me.
    Thanks in Advance
    Uday.

    I hope this can help you:
    package it.test
    import java.awt.BorderLayout;
    import java.awt.Frame;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.Locale;
    import javax.swing.JButton;
    import javax.swing.JDialog;
    import javax.swing.JFileChooser;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.SwingUtilities;
    import javax.swing.UIManager;
    * @author Alessandro
    public class Test extends JDialog {
         private JFileChooser fc = null;
         private Frame bfcParent = null;
         public Test(Frame parent, boolean modal) {
              super(parent, modal);
              this.bfcParent = parent;
              if (fc == null) {
                   fc = new JFileChooser();
                   fc.setAcceptAllFileFilterUsed(false);
                   fc.setLocale(Locale.ITALIAN);//i think you should use english
                   //these are in telugu
                   UIManager.put("FileChooser.openDialogTitleText", "Open Dialog");
                   UIManager.put("FileChooser.saveDialogTitleText", "Save Dialog");
                   UIManager.put("FileChooser.lookInLabelText", "LookIn");
                   UIManager.put("FileChooser.saveInLabelText", "SaveIn");
                   UIManager.put("FileChooser.upFolderToolTipText", "UpFolder");
                   UIManager.put("FileChooser.homeFolderToolTipText", "HomeFolder");
                   UIManager.put("FileChooser.newFolderToolTipText", "New FOlder");
                   UIManager.put("FileChooser.listViewButtonToolTipText", "View");
                   UIManager.put("FileChooser.detailsViewButtonToolTipText", "Details");
                   UIManager.put("FileChooser.fileNameHeaderText", "Name");
                   UIManager.put("FileChooser.fileSizeHeaderText", "Size");
                   UIManager.put("FileChooser.fileTypeHeaderText", "Type");
                   UIManager.put("FileChooser.fileDateHeaderText", "Date");
                   UIManager.put("FileChooser.fileAttrHeaderText", "Attr");
                   UIManager.put("FileChooser.fileNameLabelText", "Label");
                   UIManager.put("FileChooser.filesOfTypeLabelText", "filesOfType");
                   UIManager.put("FileChooser.openButtonText", "Open");
                   UIManager.put("FileChooser.openButtonToolTipText", "Open");
                   UIManager.put("FileChooser.saveButtonText", "Save");
                   UIManager.put("FileChooser.saveButtonToolTipText", "Save");
                   UIManager.put("FileChooser.directoryOpenButtonText", "Open Directory");
                   UIManager.put("FileChooser.directoryOpenButtonToolTipText", "Open Directory");
                   UIManager.put("FileChooser.cancelButtonText", "Cancel");
                   UIManager.put("FileChooser.cancelButtonToolTipText", "Cancel");
                   UIManager.put("FileChooser.newFolderErrorText", "newFolder");
                   UIManager.put("FileChooser.acceptAllFileFilterText", "Accept");
                   fc.updateUI();
         public int openFileChooser() {
              fc.setDialogTitle("Open File");
              fc.resetChoosableFileFilters();
              int returnVal = 0;
              fc.setDialogType(JFileChooser.OPEN_DIALOG);
              returnVal = fc.showDialog(this.bfcParent, "Apri File");
              //Process the results.
              if (returnVal == JFileChooser.APPROVE_OPTION) {
                   System.out.println("Hai scelto di aprire un file");
              } else {
                   System.out.println("hai annullato l'apertura");
              return returnVal;
         private static void createAndShowGUI() {
              JFrame frame = new JFrame("FileChooser");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              JPanel jp = new JPanel(new BorderLayout());
              JButton openButton = new JButton("Open File");
              final Test test = new Test(frame, true);
              openButton.addActionListener(new ActionListener() {
                   @Override
                   public void actionPerformed(ActionEvent e) {
                        test.openFileChooser();
              openButton.setEnabled(true);
              jp.add(openButton, BorderLayout.AFTER_LAST_LINE);
              //Add content to the window.
              frame.add(jp);
              //Display the window.
              frame.pack();
              frame.setVisible(true);
         public static void main(String[] args) {
              //Schedule a job for the event dispatch thread:
              //creating and showing this application's GUI.
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        //Turn off metal's use of bold fonts
                        createAndShowGUI();
    }bye ale

  • How to find files and subdirectories in a directory

    can anyone tell me how to find files and subdirectories in a directory .

    Here's a code snippet,
    http://javaalmanac.com/egs/java.io/TraverseTree.html

Maybe you are looking for

  • Help my safari doesn't work

    Process:         Safari [1057] Path:            /Applications/Safari.app/Contents/MacOS/Safari Identifier:      com.apple.Safari Version:         7.0 (9537.71) Build Info:      WebBrowser-7537071000000000~3 Code Type:       X86-64 (Native) Parent Pro

  • If I change a file name, how can I get all the links to update?

    I've recently finished my webpage (kensingtonconcertseries.com),.....then my client wanted to change the name of one of his pages from 'Marold Duo' to 'Rodewald-Morebello Duo.' All of my links to that page are to the original page(MaroldDuo.html). Ar

  • Universal Bluetooth headset-deskphone adapter?

    Looking for a solution that will let me use a Bluetooth headset with iPhone and my office phone. (Complication: the office phone is a Cisco IP phone, not analog line.) I know of the Plantronics "Voyager 510 USB" with Bluetooth adapter, which is said

  • Print Layout Designer:Due date in Delivery document

    In print layout designer in 2005 version for Delivery document when they preview the document in document printing it compute an automatic due date but if the preview was done in the delivery document itself the due date is the same as posting date.

  • Using LOTS of Data

    So I just noticed that my computer is using a TON of data. I recently switched over from AT&T Edge network on Sunday Night, and now I am on Verizon 3G all the time. We have an unlimited data plan which is good, but I don't understand why I am using a