Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Access Denied when extracting zip file.

  1. #1
    Member
    Join Date
    Apr 2011
    Posts
    32
    Thanks
    2
    Thanked 1 Time in 1 Post

    Question Access Denied when extracting zip file.

    I'm attempting to create an installer of sorts. When created, everything is stored inside a zip file named DATA.mpk and then put inside the jarfile for distribution.

    The structure looks like this

    Jar.jar
    --DATA.mpk
    ----INJAR
    ------files
    ----mc
    ------files
    --classes


    Here's my current extraction code:
    //DATA.mpk
    			System.out.println(dataDir.canRead() + ":" + dataDir.canWrite() + ":" + dataDir.canExecute());
    			try
    			{
    				//gimme
    				copyInputStream(Extractor.class.getResourceAsStream("DATA.mpk"), new BufferedOutputStream(new FileOutputStream(".DATA.mpk")));
     
    				//nowgo
    				ZipFile zipFile = new ZipFile(".DATA.mpk");
     
    				Enumeration<? extends ZipEntry> entries = zipFile.entries();
     
    				while(entries.hasMoreElements()) {
    					String path = "DATA/";
    					ZipEntry entry = (ZipEntry)entries.nextElement();
    					if(!entry.getName().contains("META-INF")){
    						File file = new File(entry.getName()); 
    						try{
    							if(file.getParent() != null);
    							StringBuilder finalPath = new StringBuilder();
    							finalPath.append("DATA/");
    							String[] structure = entry.getName().split("/");
    							for (int i=0; i<structure.length -1; i++){
    								finalPath.append(structure[i]).append("/");
    							}
    							File parentDir = new File(finalPath.toString());
    							parentDir.mkdirs();
    						}catch(Exception e){
     
    						}
     
    						System.out.println("Extracting datafile: " + entry.getName());
    						copyInputStream(zipFile.getInputStream(entry), new BufferedOutputStream(new FileOutputStream(path + entry.getName())));
    					}else{
    						continue;
    					}
    				}
    				zipFile.close();
     
    			}
    			catch (Exception e)
    			{
    				e.printStackTrace();
    				return false;
    			}
    			File df = new File("DATA.mpk");
    			df.delete();

    According to the debug line, I have read/write/execute permissions on the directory, but when it attempts to extract the INJAR folder, it throws FileNotFoundException (Access is denied).

    Not sure where the issue is. There's a clause before the above code that successfully unzips a jarfile already on my computer, I'm adding stuff to it using the above clause and then re-zipping everything up.

    Here's the exact error:

    true:true:true
    java.io.FileNotFoundException: DATA\INJAR (Access is denied)
    	at java.io.FileOutputStream.open(Native Method)
    	at java.io.FileOutputStream.<init>(Unknown Source)
    	at java.io.FileOutputStream.<init>(Unknown Source)
    	at techwiz24.McRepack.Extractor.Extractor$install.doInstall(Extractor.java:210)
    	at techwiz24.McRepack.Extractor.Extractor$install.run(Extractor.java:98)
    	at techwiz24.McRepack.Extractor.Extractor$install.doAction(Extractor.java:111)
    	at techwiz24.McRepack.Extractor.Extractor$2.actionPerformed(Extractor.java:78)
    	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)Extracting datafile: INJAR/
     
    	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    	at java.awt.Component.processMouseEvent(Unknown Source)
    	at javax.swing.JComponent.processMouseEvent(Unknown Source)
    	at java.awt.Component.processEvent(Unknown Source)
    	at java.awt.Container.processEvent(Unknown Source)
    	at java.awt.Component.dispatchEventImpl(Unknown Source)
    	at java.awt.Container.dispatchEventImpl(Unknown Source)
    	at java.awt.Component.dispatchEvent(Unknown Source)
    	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    	at java.awt.Container.dispatchEventImpl(Unknown Source)
    	at java.awt.Window.dispatchEventImpl(Unknown Source)
    	at java.awt.Component.dispatchEvent(Unknown Source)
    	at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    	at java.awt.EventQueue.access$000(Unknown Source)
    	at java.awt.EventQueue$1.run(Unknown Source)
    	at java.awt.EventQueue$1.run(Unknown Source)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
    	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
    	at java.awt.EventQueue$2.run(Unknown Source)
    	at java.awt.EventQueue$2.run(Unknown Source)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
    	at java.awt.EventQueue.dispatchEvent(Unknown Source)
    	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    	at java.awt.EventDispatchThread.run(Unknown Source)
    Last edited by techwiz24; December 18th, 2011 at 07:48 PM.


  2. #2
    Member
    Join Date
    Apr 2011
    Posts
    32
    Thanks
    2
    Thanked 1 Time in 1 Post

    Default Re: Access Denied when extracting zip file.

    Nevermind I had already created the directory in the code. Crap...

Similar Threads

  1. access denied (java.io.FilePermission "report.jrxml" read)
    By banny7 in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: November 3rd, 2011, 06:02 AM
  2. Problem extracting data from file
    By hello_world in forum File I/O & Other I/O Streams
    Replies: 17
    Last Post: August 21st, 2011, 09:35 PM
  3. JFileChooser save dialog box "access is denied" error
    By byrdman in forum What's Wrong With My Code?
    Replies: 7
    Last Post: August 2nd, 2011, 01:45 PM
  4. Replies: 6
    Last Post: August 18th, 2010, 05:41 PM
  5. Extracting the BINDING element from WSDL file
    By Sai in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 26th, 2010, 02:56 AM