How can I rename a ZIP File??

Hi all,
I need to create a Zip file and once it's created, I have to change it's name. The code I've developed is the following:
String[] filenames = new String[]{"newUsers.csv"};
        byte[] buf = new byte[1024];
        try {
            ZipOutputStream out = new ZipOutputStream( new FileOutputStream("newUsers.zip"));
            for (int i=0; i<filenames.length; i++){
                FileInputStream in = new FileInputStream(filenames);
out.putNextEntry(new ZipEntry(filenames[i]));
int len;
while ((len = in.read(buf)) > 0){
out.write(buf, 0, len);
out.closeEntry();
in.close();
out.close();
} catch (IOException e) {
e.printStackTrace();
}This code creates my ZIP, what do I have to do to change it's name once it's finished? I home that someone can help me, it's quite urgent                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Thanks!! It's now working correctly, the final code is the following:
File ftemp = new File("newUsersTEMP.zip");
            File fnew = new File("newUsers.zip");
            ZipOutputStream out = new ZipOutputStream( new FileOutputStream(ftemp));
            for (int i=0; i<filenames.length; i++){
                FileInputStream in = new FileInputStream(filenames);
out.putNextEntry(new ZipEntry(filenames[i]));
int len;
while ((len = in.read(buf)) > 0){
out.write(buf, 0, len);
out.closeEntry();
in.close();
out.close();
fnew.delete();
ftemp.renameTo(new File("newUsers.zip"));                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • How can i rename a jar file using only java code

    i have tried everything i can think of to accomplish this but nothing works.

    ghostbust555 wrote:
    In case you geniuses haven't realized I said I tried everything I can think of not that I tried everything. So help or shut up I realize that I didn't try everything but if you can't figure it out either DO NOT POST.
    And the question is how can i rename a jar file using java code? As it says in the title. Read.I would tell you to use the File.renameTo method, but surely that would have been obvious, and you would have tried it already? But maybe you didn't. You were kind of lacking in details in what you tried.
    And yes, I am a genius. Just don't confuse "genius" with "mind-reader".

  • How can I rename open PDF files on my android tablet

    How can I rename open files on android tablet

    However, you can rename a file from document browser like this : http://forums.adobe.com/message/4753337

  • How can i create a zip-file with multiple volumes

    Hi,
    i've to zip a large file (250 MB and more). But the zip file shouldn't be greater than 5 MB, because i have to send the file via E-Mail. So i've thought, that the solution of this problem can be to zip the large file in smaller zip-files, which are multiple volumes of a zip-archive. I've searched very long in WWW, but didn't find something. Perhaps you can help.
    Sorry, about the bad english. :-)
    Timo Bunger

    Hi
    Who said your english is bad ?. OK, are you looking for compressing the 250 MB file in to multiple versions using a java program ?. If not, there is a shareware you can download and split the file into multiple parts by specifying size of each part. You can send these parts via email and the other person can combine these parts into a single file again.
    Find this @
    http://www.freedownloadscenter.com/Utilities/File_Splitting_Utilities/EzSplit.html
    You may need to read a bit about it on how to use.
    Thanks
    Srinivas

  • How can I create a zip file with LabVIEW?

    I would like to compress my data (ASCII format) to an archive.
    I use LVZlib.vi to compress and decompress data but I would like to be able to read the output file with a software archiver such as PowerArchiver/WinZIP.
    Someone knows how I can create a file compatible with zip or gz standard format, thanks !

    >> Yes but I have to install a special archiver (with ms-dos ommand line ability
    >> such as pkzip,arc,rar,arj...) on the computer where I install my LV application.
    Search for "gnu tools for windows" and get zip.exe, gzip.exe, bzip2.exe and others (even the source, if you like). These are about 50kB files that run in place (no installation) - easy to include in a distributed app. Oh, since I'm logged in I'll attach a couple, though I don't have the source on this machine).
    Attachments:
    bin.zip ‏67 KB

  • How can I send a zip file from ipad to laptop via bluetooth

    My laptop wont connect to the internet so, i want to send it files via bluetooth from my ipad. The files are zip files

    This is not possible with the bluetooth that iPad has.

  • How can I rename files without creating a duplicate?

    How can I rename files without creating a duplicate?  And secondly, for some reason I can no longer save pdf files [i.e., bank statements] where I want - the Save As function is gone?

    In many new cases, Save As is now called Duplicate in ML. It uses the same command-S keystroke. Older apps still have Save As. When you do a Duplicate operation, you will create an UNTITLED document. You have to save that duplicated document to complete the process.
    So in 10.6.x, you would do ...
    * Save As ...
    * Give the file a new name + Chose the location for the file
    * Click the Save button
    Now in 10.8.x, you do ...
    * Duplicate ...
    * Save ...
    * Give the file a name + Chose the location for the file
    * Click the Save button
    As baltwo mentioned, you have to search the Preferences of your browser to determine what is has set for the default Download folder.
    JJW

  • How can I rename my pics in Bridge CS5?

    How can I renams my pics in Bridge CS5?

    Here's what is in the Bridge cs5 help pdf file.  (I was not able to find this same help info from clicking help in Bridge cs5).
    Batch rename files
    You can rename files in a group, or batch. When you batch rename files, you can choose the same settings for all the selected files. For other batch-processing tasks, you can use scripts to run automated tasks.
    1  Select the files that you want to rename.
    2  Choose Tools > Batch Rename.
    3  Set the following options:
    Destination Folder
    Place the renamed files in the same folder, move them to another folder, or place copies in another folder. If you choose to put the renamed files in a different folder, click Browse to select the folder.
    New Filenames
    Choose elements from the menus and enter text as appropriate to create new filenames. Click the Plus button [+] or Minus button [-] to add or delete elements.
    •String Substitution
    Allows you to change all or part of a filename to custom text. First, choose what you want to replace: Original Filename replaces the string from the original filename. Intermediate Filename replaces a string that is defined by preceding options in the New Filenames pop-up menus. Use Regular Expression allows you to use regular expressions to find strings based on patterns in filenames. Replace All replaces all substrings that match the pattern in the source string.
    Options
    Select Preserve Current Filename In XMP Metadata to retain the original filename in the metadata. For Compatibility, select the operating systems with which you want renamed files to be compatible. The current operating system is selected by default, and cannot be deselected.
    Preview
    One current and new filename appear in the Preview area at the bottom of the Batch Rename dialog box. To see how all selected files will be renamed, click the Preview button.
    4  (Optional) Select a preset from the Presets menu to renaming with frequently used naming schemes. To save batch rename settings for reuse, click Save.

  • How Can I get a HeapDump file in JRockit R26.3 or latter version

    I had tried "-Djrockit.oomdiagnostics.filename=oom.txt" arg,but it didn't work.
    how can i get a heapdump file in JRockit R26.3 or latter version ?
    I can only get the under infomation by using a ctrlhandler.act file.
    ======== BEGIN OF HEAPDIAGNOSTIC =========================
    Invoked from ctrlbreakhandler
    Total memory in system: 402075648 bytes
    Available physical memory in system: 54231040 bytes
    -Xmx (maximal heap size) is 314572800 bytes
    Heapsize: 314572800 bytes
    Free heap-memory: 0 bytes
    mmStartCompaction = 0x01DC0000, mmEndCompaction = 0x03080000
    3 GB mode was not used
    --------- Detailed Heap Statistics: ---------
    59.1% 110757k 1360491 +110757k [C
    17.0% 31916k 1361767 +31916k java/lang/String
    16.6% 31021k 1323579 +31021k java/util/HashMap$Entry
    4.7% 8766k 1909 +8766k [Ljava/util/HashMap$Entry;
    0.8% 1470k 2256 +1470k [B
    0.3% 491k 480 +491k [Lweblogic/servlet/utils/URLMatchMap$URLMatchNode;
    0.2% 342k 4871 +342k java/lang/Class
    0.2% 283k 3942 +283k [Ljava/lang/Object;
    0.1% 215k 1536 +215k [I
    0.1% 172k 7376 +172k java/util/Hashtable$Entry
    0.1% 157k 1552 +157k weblogic/management/tools/AttributeInfo
    0.0% 83k 2421 +83k [Ljava/lang/String;
    0.0% 83k 299 +83k [Ljava/util/Hashtable$Entry;
    0.0% 74k 1900 +74k java/util/HashMap
    0.0% 71k 1530 +71k java/lang/reflect/Method
    0.0% 62k 472 +62k weblogic/servlet/internal/ServletStubImpl
    0.0% 61k 461 +61k weblogic/management/runtime/ServletRuntimeMBean_Stub
    0.0% 55k 2383 +55k java/util/ArrayList
    0.0% 50k 3227 +50k java/lang/Integer
    0.0% 48k 1552 +48k weblogic/management/internal/DynamicMBeanImpl$XAttributeInfo
    0.0% 48k 1229 +48k java/util/WeakHashMap$Entry
    0.0% 43k 1840 +43k java/lang/ref/WeakReference
    0.0% 41k 528 +41k weblogic/rmi/internal/MethodDescriptor
    0.0% 38k 1768 +38k [Ljava/lang/Class;
    0.0% 38k 1637 +38k javax/management/modelmbean/DescriptorSupport$Pair
    0.0% 37k 805 +37k weblogic/management/WebLogicObjectName
    0.0% 34k 480 +34k [Lweblogic/servlet/utils/URLMatchMap$URLExtensionNode;
    0.0% 33k 532 +33k weblogic/management/tools/OperationInfo
    0.0% 32k 461 +32k weblogic/servlet/internal/ServletRuntimeMBeanImpl
    0.0% 30k 982 +30k java/lang/ref/SoftReference
    0.0% 26k 419 +26k weblogic/servlet/internal/dd/ServletDescriptor
    0.0% 20k 423 +20k [Lweblogic/utils/collections/ConcurrentHashMap$Entry;
    0.0% 19k 423 +19k weblogic/utils/collections/ConcurrentHashMap
    0.0% 19k 1222 +19k java/util/jar/Attributes$Name
    0.0% 18k 100 +18k [Ljava/lang/reflect/Method;
    0.0% 17k 447 +17k weblogic/servlet/utils/URLMatchMap$URLMatchNode
    0.0% 17k 12 +17k [J
    0.0% 16k 425 +16k weblogic/servlet/internal/dd/UIDescriptor
    0.0% 16k 684 +16k javax/management/MBeanParameterInfo
    0.0% 15k 480 +15k weblogic/servlet/utils/URLMatchMap
    0.0% 14k 471 +14k java/util/TreeMap$Entry
    0.0% 14k 453 +14k javax/management/modelmbean/DescriptorSupport
    0.0% 14k 638 +14k [Ljavax/management/MBeanParameterInfo;
    0.0% 13k 431 +13k weblogic/servlet/internal/dd/ServletMappingDescriptor
    0.0% 13k 852 +13k com/octetstring/vde/syntax/DirectoryString
    0.0% 13k 431 +13k [S
    0.0% 12k 553 +12k java/util/Vector
    0.0% 11k 302 +11k java/lang/Package
    0.0% 11k 369 +11k weblogic/xml/util/TernarySearchTree$Node
    0.0% 11k 727 +11k java/lang/Boolean
    0.0% 10k 266 +10k java/util/Hashtable
    0.0% 9k 182 +9k java/net/URL
    0.0% 9k 15 +9k [Ljava/util/WeakHashMap$Entry;
    0.0% 9k 386 +9k weblogic/rmi/internal/ClientMethodDescriptor
    0.0% 8k 158 +8k com/octetstring/vde/schema/AttributeType
    0.0% 8k 90 +8k weblogic/logging/WLServerLogRecord
    0.0% 8k 211 +8k weblogic/management/commo/CommoModelMBeanAttributeInfo
    0.0% 8k 2 +8k [Lcom/octetstring/vde/backend/standard/KeyPtr;
    0.0% 7k 322 +7k jrockit/vm/FCECache$FCE
    0.0% 7k 471 +7k weblogic/servlet/internal/URLMatchHelper
    0.0% 7k 58 +7k [Lweblogic/management/tools/AttributeInfo;
    0.0% 7k 58 +7k [Lweblogic/management/internal/DynamicMBeanImpl$XAttributeInfo;
    0.0% 6k 288 +6k weblogic/utils/collections/ConcurrentHashMap$Entry
    0.0% 6k 431 +6k java/util/HashMap$EntrySet
    0.0% 6k 428 +6k java/util/jar/Attributes
    0.0% 6k 156 +6k jrockit/memory/SoftCache$ValueCell
    0.0% 5k 379 +5k java/lang/Long
    0.0% 5k 751 +5k java/lang/Object
    0.0% 5k 77 +5k java/util/GregorianCalendar
    0.0% 5k 231 +5k java/util/LinkedList$Entry
    0.0% 5k 32 +5k weblogic/kernel/ExecuteThread
    0.0% 4k 25 +4k weblogic/rmi/internal/BasicRuntimeDescriptor
    0.0% 4k 111 +4k [Z
    0.0% 4k 204 +4k com/octetstring/vde/backend/standard/KeyPtr
    0.0% 4k 301 +4k com/bea/utils/misc/ProcessProperty
    0.0% 4k 49 +4k weblogic/apache/xerces/impl/dv/xs/XSSimpleTypeDecl
    0.0% 4k 73 +4k weblogic/jndi/internal/ApplicationNamingNode
    0.0% 4k 58 +4k weblogic/management/tools/Info
    0.0% 4k 290 +4k java/lang/Byte
    0.0% 4k 289 +4k java/lang/Short
    0.0% 4k 57 +4k [Ljava/lang/ThreadLocal$ThreadLocalMap$Entry;
    0.0% 4k 275 +4k java/lang/Character
    0.0% 4k 108 +4k java/math/BigInteger
    0.0% 4k 60 +4k weblogic/management/commo/ModelMBeanTypeMBean
    0.0% 4k 106 +4k java/util/TreeMap
    0.0% 4k 172 +4k java/text/EntryPair
    0.0% 3k 99 +3k weblogic/management/commo/CommoModelMBeanOperationInfo
    0.0% 3k 12 +3k weblogic/management/configuration/WebAppComponentMBean_Stub
    0.0% 3k 81 +3k sun/util/calendar/ZoneInfo
    0.0% 3k 9 +3k [Lweblogic/utils/collections/WeakConcurrentHashMap$Entry;
    0.0% 3k 95 +3k sun/misc/SoftCache$ValueCell
    0.0% 3k 93 +3k weblogic/management/commo/CommoModelMBeanInfoSupport
    0.0% 3k 115 +3k weblogic/servlet/internal/dd/ParameterDescriptor
    0.0% 3k 108 +3k javax/management/ObjectName
    0.0% 3k 104 +3k java/lang/StackTraceElement
    0.0% 3k 137 +3k java/io/ExpiringCache$Entry
    0.0% 3k 58 +3k [Lweblogic/management/tools/OperationInfo;
    0.0% 3k 7 +3k weblogic/servlet/internal/WebAppServletContext
    0.0% 3k 49 +3k jrockit/vm/ObjectMonitor
    0.0% 2k 191 +2k java/util/HashSet
    0.0% 2k 91 +2k java/util/ResourceBundle$LoaderReference
    0.0% 2k 121 +2k weblogic/management/commo/Commo$Pair
    0.0% 2k 4 +2k [Ljrockit/vm/FCECache$FCE;
    0.0% 2k 7 +2k [[Ljava/lang/String;
    0.0% 2k 30 +2k weblogic/management/internal/ConfigurationMBeanImpl
    0.0% 2k 107 +2k jrockit/reflect/VirtualNativeMethodInvoker
    0.0% 2k 12 +2k weblogic/management/configuration/ApplicationMBean_Stub
    0.0% 2k 73 +2k java/lang/ThreadLocal$ThreadLocalMap$Entry
    0.0% 2k 97 +2k java/util/LinkedList
    0.0% 2k 95 +2k weblogic/apache/xerces/util/SymbolHash$Entry
    0.0% 2k 56 +2k com/octetstring/vde/schema/ObjectClass
    0.0% 2k 93 +2k sun/security/util/ObjectIdentifier
    0.0% 2k 92 +2k java/util/ResourceBundle$ResourceCacheKey
    0.0% 2k 92 +2k java/util/regex/Pattern$Range
    0.0% 2k 91 +2k com/octetstring/vde/backend/standard/KeyEidList
    0.0% 2k 25 +2k [Lweblogic/management/commo/CommoModelMBeanAttributeInfo;
    0.0% 2k 12 +2k weblogic/management/mbeans/custom/Application
    0.0% 1k 25 +1k [Lweblogic/rmi/internal/MethodDescriptor;
    0.0% 1k 81 +1k weblogic/management/internal/Pair
    0.0% 1k 30 +1k com/bea/utils/misc/Process
    0.0% 1k 86 +1k [Lweblogic/management/WebLogicObjectName;
    0.0% 1k 58 +1k weblogic/management/internal/DynamicMBeanImpl$XInfo
    0.0% 1k 33 +1k sun/net/www/protocol/jar/URLJarFile
    0.0% 1k 38 +1k java/util/jar/JarFile
    0.0% 1k 74 +1k javax/management/NotificationBroadcasterSupport$Triple
    0.0% 1k 72 +1k com/sun/management/jmx/MBeanServerNotificationListener
    0.0% 1k 12 +1k weblogic/management/mbeans/custom/WebAppComponent
    0.0% 1k 72 +1k weblogic/management/internal/OnewayNotificationListenerImpl
    0.0% 1k 4 +1k [Lcom/sun/corba/se/internal/util/IdentityHashtableEntry;
    0.0% 1k 30 +1k [Lcom/bea/utils/misc/ProcessProperty;
    0.0% 1k 70 +1k java/util/Collections$SynchronizedList
    0.0% 1k 2 +1k weblogic/management/configuration/ServerMBean_Stub
    0.0% 1k 51 +1k weblogic/rmi/internal/PhantomRef
    0.0% 1k 3 +1k [Ljava/util/TimerTask;
    0.0% 1k 49 +1k weblogic/apache/xerces/dom/DeferredAttrImpl
    0.0% 1k 39 +1k weblogic/jndi/internal/WLEventContextImpl
    0.0% 1k 19 +1k weblogic/rmi/internal/BasicServerRef
    0.0% 1k 92 +1k jrockit/memory/AtomicIntImpl
    0.0% 1k 90 +1k weblogic/utils/DebugCategory
    0.0% 1k 59 +1k javax/management/loading/MLetContent
    0.0% 1k 16 +1k java/util/jar/JarFile$JarFileEntry
    0.0% 1k 87 +1k weblogic/utils/collections/Stack
    0.0% 1k 57 +1k java/lang/ThreadLocal$ThreadLocalMap
    0.0% 1k 13 +1k weblogic/jndi/internal/AdminRoleBasedDispatchServerRef
    0.0% 1k 13 +1k [Ljava/lang/Byte;
    0.0% 1k 41 +1k weblogic/xml/babel/scanner/Token
    0.0% 1k 25 +1k [Lweblogic/management/commo/CommoModelMBeanOperationInfo;
    0.0% 1k 53 +1k java/util/Collections$SynchronizedRandomAccessList
    0.0% 1k 52 +1k java/util/Date
    0.0% 1k 12 +1k java/text/DecimalFormat
    0.0% 1k 38 +1k sun/misc/URLClassPath$JarLoader
    0.0% 1k 6 +1k weblogic/management/runtime/WebAppComponentRuntimeMBean_Stub
    0.0% 1k 15 +1k [Lweblogic/apache/xerces/util/SymbolHash$Entry;
    0.0% 1k 48 +1k java/util/Locale
    0.0% 1k 14 +1k weblogic/common/internal/PeerInfo
    0.0% 1k 20 +1k sun/nio/cs/ext/GBK$Encoder
    0.0% 1k 44 +1k [Ljavax/management/NotificationBroadcasterSupport$Triple;
    0.0% 1k 23 +1k weblogic/jndi/internal/ServerNamingNode
    0.0% 1k 20 +1k [[B
    0.0% 1k 27 +1k java/lang/reflect/Constructor
    0.0% 1k 33 +1k java/util/zip/Inflater
    0.0% 1k 1 +1k [Ljava/lang/Character;
    0.0% 1k 1 +1k [Ljava/lang/Short;
    0.0% 1k 1 +1k [Ljava/lang/Integer;
    0.0% 1k 43 +1k sun/security/util/DerValue
    0.0% 1k 43 +1k sun/security/util/DerInputBuffer
    0.0% 1k 43 +1k java/security/AccessControlContext
    0.0% 0k 9 +0k java/lang/Thread
    0.0% 0k 21 +0k java/util/Properties
    0.0% 0k 31 +0k java/util/Collections$SynchronizedSortedMap
    0.0% 0k 31 +0k weblogic/servlet/utils/URLMatchMap$URLExtensionNode
    0.0% 0k 4 +0k weblogic/management/configuration/JMSQueueMBean_Stub
    0.0% 0k 11 +0k weblogic/kernel/ExecuteThreadManager
    0.0% 0k 6 +0k weblogic/j2ee/J2EEApplicationContainer
    0.0% 0k 20 +0k java/nio/HeapByteBuffer
    187413kB total ---
    --------- End of Detailed Heap Statistics ---
    ------------------- Printing heap ---------------------
    "o"/"p" = 1k normal/pinned objects
    "O"/"P" = 50k normal/pinned objects
    "."/"/" = <1k normal/pinned objects (fragmentation)
    " "/"_" = 1k/50k free space
    OOOOoooooooooooooooooooooooooooooooooooooooooooooo     0x00B3BD08
    ........oooooooooooooooooooooooooooooooooooooooooo     0x00B48058
    oooo....ooooooooooooooooooooo.....ooo..........OOO     0x00B6C278
    OOOOooooooooooooooooooooooo....ooooooooooooooooooo     0x00BB42D0
    oooooooooooooo.ooo..oooooooooooooooooooooooooooooo     0x00BC0620
    oooooooooooooo.Ooooooooooooooooooooooooooooooooooo     0x00BD88D8
    oo.....Ooooooooooooooooooooooooooooooooooooooooo..     0x00BF0B90
    ...oooooooooooooooooooooooooooooooooooooooooooo...     0x00BFCEE0
    ...ooooo.....................................Ooooo     0x00C15198
    oooooooooooooooooooooooooooooooooo................     0x00C214E8
    ......o........oooo.oooooo....oo.Ooooooooooooooooo     0x00C397A0
    ooooooooooooo.............................Oooooooo     0x00C51A58
    ooooooooooooooooooooooooooooooo. . ...oooooooooooo     0x00C5DDA8
    o..........................ooooooooooooooooooooooo     0x00C6A0F8
    oooooooooooooooooooooo........ooo..o...ooooooooooo     0x00C76448
    .......

    Hi all,
    We have HPROF functionality in our latest roadmap, so you will see that feature in our next major release called JRockit R28.
    I recommend, above from the MemLeak documentation suggested by Makiey, the following information on how to use JRockit tools.
    Performance Tuning & Profiling:
    http://download.oracle.com/docs/cd/E13150_01/jrockit_jvm/jrockit/geninfo/diagnos/part_02.html
    Using JRockit tools:
    http://download.oracle.com/docs/cd/E13150_01/jrockit_jvm/jrockit/geninfo/diagnos/part_03.html
    Diagnostics & Troubleshooting
    http://download.oracle.com/docs/cd/E13150_01/jrockit_jvm/jrockit/geninfo/diagnos/part_04.html
    Best Regards,
    Tuva
    JRockit PM

  • Can't open the Zipped file

    Hi
    I am making a zip file using GZIPOutputStream. But I am not able to open the zip file that is created using win zip.The size of the zipped file is 81 KB and the input file is 3,245 KB.I have closed all the streams still I am not able to figure out the problem.Any idea where I am going wrong ? Any help would be greatly appreciated.
    Here my code goes:
    import java.util.zip.*;
    import java.io.*;
    public class ZipFile
         public static void main(String[] args) throws FileNotFoundException,IOException
              ZipFile("D:\\Java\\Test\\INPUTXML_bkp_1.xml");
         public static String ZipFile(String fileName) throws FileNotFoundException,IOException
              String name = fileName.substring(fileName.lastIndexOf('\\') +1 ,fileName.lastIndexOf('.'));
              String filePath = fileName.substring(0,fileName.indexOf(name));
              String newFileName = new StringBuffer(name).append(".zip").toString();
              FileOutputStream outputStream = new FileOutputStream(newFileName);
              GZIPOutputStream zipOutputStream = new GZIPOutputStream(outputStream);
              FileInputStream inputStream = new FileInputStream(fileName);
              byte[] temp = new byte[10000000];
              int counter = inputStream.read(temp,0,temp.length);
              zipOutputStream.write(temp,0,counter);
              inputStream.close();
              zipOutputStream.finish();
              zipOutputStream.close();
              return newFileName;
    Thanks
    Ritesh

    Thanks for the reply.
    I changed my code to look like this:
    import java.util.zip.*;
    import java.io.*;
    public class ZipFile
         public static void main(String[] args) throws FileNotFoundException,IOException
              ZipFile("D:\\Java\\Test\\INPUTXML_bkp_1.xml");
         public static String ZipFile(String fileName) throws FileNotFoundException,IOException
              String name = fileName.substring(fileName.lastIndexOf('\\') +1 ,fileName.lastIndexOf('.'));
              String filePath = fileName.substring(0,fileName.indexOf(name));
              String newFileName = new StringBuffer(name).append(".zip").toString();
              FileOutputStream outputStream = new FileOutputStream(newFileName);
              ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream);
              ZipEntry zipEntry = new ZipEntry(fileName);
              zipOutputStream.putNextEntry(zipEntry);
              zipOutputStream.finish();
              zipOutputStream.close();
              return newFileName;
    Now I can atleast open the zip file. But the problem is the size of the file is 0 kb. Probably because, I am not populating the Zip entry. Can u pls let me know how do I do that.
    Thanks
    Ritesh

  • Can we read a ZIP file through ESB file adapter?

    Hi,
    Is it possible to read a ZIP file from a specified locaiton either through a FTP adapter or file adapter as a opaque element and place it in another specified locaiton?
    So far the available options are to read a txt, csv, fixed length or cobol file.
    I tried to create a ESB reading ZIP file and place it in another locaiton. but it was not reading the ZIP file.
    Is it first possible for the ESB to read the ZIP file? if so then is there any specific configuratuion that we have to do for it to work?

    how can we read a MSWORD file through java?You can read it like any other file using FileInputStream
    and similar.
    Howvere, if you want do do something with it, like display
    it, you have a problem. AFAIK Microsoft do not release
    information about their document formats, and i have not
    seen a .doc viewer for java.

  • What is .PESVWSH file & how can I recover my previous file extension?

    Dear Sir,
    I have facing trouble opening any file. all file has convert automatically to .pesvwsh extension. After rename this file and try to open but not open and showing "the file can not be opened because there are problems with the content."
    Please help me how can i recover my all files and let me what is the pesvwsh file.
    Thanks & Best regards,
    Md. Anisur Rahman

    Hello,
    The 'Suggestions and Feedback for the Forums' forum is to give users a voice on Forums. Users can give suggestions for improvements or vote up suggestions and know that the Forums team is listening.
    I'd ask in the Virus and Malware forum on Microsoft Community, or the
    Windows forum on Microsoft Community.
    As the Microsoft Community is on a different platform, we cannot move the question for you.
    Once there, click on Participate near the top of the screen, and select 'Ask a Question' or 'Start a Discussion':
    Karl
    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer.
    My Blog: Unlock PowerShell
    My Book:
    Windows PowerShell 2.0 Bible
    My E-mail: -join ('6F6C646B61726C406F75746C6F6F6B2E636F6D'-split'(?<=\G.{2})'|%{if($_){[char][int]"0x$_"}})

  • I backed up my bookmarks to an external drive, rebuilt my system, and now when I try to restore from that file, I get "unsupported file type" How can I restore from this file?

    I backed up my bookmarks to an external drive, rebuilt my system, and now when I try to restore from that file, I get "unsupported file type" How can I restore from this file?

    Make sure that the backup file with the bookmarks has the correct file extension: .html for a HTML backup and .json for a JSON backup.<br />
    You can check that via the right-click context menu of that file and open the Properties.<br />
    If you are not sure about the file type then you can open the file in Firefox via "File > Open File"<br />
    A JSON backup will show as one long text line without line breaks and a HTML backup as a web page with clickable links.<br />
    A JSON backup starts with: {"title":"","id":1,"dateAdded":<br />
    An HTML backup starts with: <nowiki><!DOCTYPE NETSCAPE-Bookmark-file-1></nowiki>
    You may need to add quotes ("") around the name to rename the file to the correct file extension.
    See also:
    * http://kb.mozillazine.org/Backing_up_and_restoring_bookmarks_-_Firefox

  • How to create a split zip file?

    Hi,
    Does anybody know how to create a split zip file using only Java?
    Lets say I have a file that compressed has a size of 10MB and I need to split it into small files of 1MB each... and then be able to open and uncompress it using winzip or any other compressing tool.
    I know how to create a zip file using java.util.zip but I cannot split it...
    Thanks,
    Ignacio

    IgnacioKriche wrote:
    Thanks for the philosophical advice...
    Can anyone help me? Does anyone know if Java API java.util.zip can split a zip file?I'm 99.9 % sure that there is nothing in the Java ZIP APIs to do this but I'm 100% sure I can't be certain.

  • How can i rename mp3 songs on iphone 4 ?

    How can i rename mp3 songs on iphone 4 ?

    You're welcome.  If you don't have your music files stored somewhere other than your iPhone, you're gonna be in a world of hurt someday.  Just sayin' ...

Maybe you are looking for