Java - Unzip and Progress Bar - java

My program uses Tasks from JavaFX to download and unzip files and to show the progress on the screen, by using the updateProgress(workDone, max) method and the progressProperty().bind(observable) method.
It works for Download :
package com.franckyi.lan.installer;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
import java.nio.file.Files;
import java.nio.file.Paths;
import javafx.concurrent.Task;
public class DownloadTask extends Task<Void> {
private String file;
private String url;
public DownloadTask(String dir, String fileurl) {
file = dir;
url = fileurl;
}
#Override
protected Void call() throws Exception {
URLConnection connection = new URL(url).openConnection();
long fileLength = connection.getContentLengthLong();
try (InputStream is = connection.getInputStream();
OutputStream os = Files.newOutputStream(Paths.get(file))) {
long nread = 0L;
byte[] buf = new byte[1024];
int n;
while ((n = is.read(buf)) > 0) {
os.write(buf, 0, n);
nread += n;
updateProgress(nread, fileLength);
}
}
return null;
}
#Override
protected void succeeded(){
System.out.println("Download succeeded");
}
}
But it doesn't work well for Unzip : The file is correctly unzipped but I get a wrong ProgressBar (empty at the end).
package com.franckyi.lan.installer;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import javafx.concurrent.Task;
public class UnZipTask extends Task<Void>{
private File zipfile;
private File folder;
public UnZipTask(File zipfile, File folder){
this.zipfile = zipfile;
this.folder = folder;
}
#Override
protected Void call() throws Exception {
ZipInputStream zis = new ZipInputStream(
new BufferedInputStream(new FileInputStream(zipfile.getCanonicalFile())));
ZipEntry ze = null;
try {
while ((ze = zis.getNextEntry()) != null) {
File f = new File(folder.getCanonicalPath(), ze.getName());
if (ze.isDirectory()) {
f.mkdirs();
continue;
}
f.getParentFile().mkdirs();
OutputStream fos = new BufferedOutputStream(new FileOutputStream(f));
try {
try {
final byte[] buf = new byte[1024];
int bytesRead;
long nread = 0L;
long length = zipfile.length();
while (-1 != (bytesRead = zis.read(buf))){
fos.write(buf, 0, bytesRead);
nread += bytesRead;
System.out.println(nread + "/" + length);
updateProgress(nread, length);
}
} finally {
fos.close();
}
} catch (final IOException ioe) {
f.delete();
throw ioe;
}
}
} finally {
zis.close();
}
return null;
}
#Override
protected void succeeded(){
System.out.println("Unzip succeeded");
}
}
This is what I get in the console :
Download succeeded
1024/91804
2048/91804
2815/91804
362/91804
326/91804
290/91804
386/91804
257/91804
250/91804
588/91804
1101/91804
1613/91804
2128/91804
2646/91804
3159/91804
3672/91804
4185/91804
4701/91804
5214/91804
5731/91804
6243/91804
6755/91804
7272/91804
7793/91804
8326/91804
8862/91804
9379/91804
9897/91804
10411/91804
10927/91804
11442/91804
11956/91804
12437/91804
447/91804
437/91804
978/91804
1525/91804
2040/91804
454/91804
1056/91804
1568/91804
2089/91804
2672/91804
3198/91804
3728/91804
4282/91804
4826/91804
5377/91804
5891/91804
6413/91804
6941/91804
7480/91804
8027/91804
8565/91804
9088/91804
9609/91804
9794/91804
507/91804
1019/91804
1531/91804
2043/91804
2239/91804
134/91804
548/91804
1292/91804
2316/91804
2584/91804
507/91804
837/91804
135/91804
486/91804
1001/91804
1514/91804
2027/91804
2545/91804
3057/91804
3571/91804
4086/91804
4599/91804
5113/91804
5627/91804
6144/91804
6655/91804
7166/91804
7679/91804
8196/91804
8710/91804
9229/91804
9745/91804
10259/91804
10773/91804
11288/91804
11802/91804
12321/91804
12834/91804
13348/91804
13864/91804
14378/91804
14893/91804
15407/91804
15918/91804
16431/91804
16944/91804
17458/91804
17971/91804
18484/91804
18997/91804
19508/91804
20021/91804
20535/91804
21047/91804
21560/91804
22072/91804
22584/91804
23096/91804
23609/91804
24122/91804
24638/91804
25149/91804
25664/91804
26176/91804
26689/91804
27203/91804
27715/91804
28227/91804
28739/91804
29251/91804
29764/91804
30277/91804
30789/91804
31301/91804
31813/91804
32325/91804
32838/91804
33306/91804
33819/91804
34333/91804
34846/91804
35357/91804
35869/91804
36381/91804
36894/91804
37407/91804
37922/91804
38435/91804
38948/91804
39460/91804
39972/91804
40488/91804
41002/91804
41514/91804
42028/91804
42540/91804
43052/91804
43566/91804
44079/91804
44594/91804
45105/91804
45619/91804
46132/91804
46644/91804
47156/91804
47668/91804
48180/91804
48692/91804
49204/91804
49716/91804
50228/91804
50741/91804
51252/91804
51765/91804
52277/91804
52790/91804
53305/91804
53821/91804
54335/91804
54852/91804
55365/91804
55881/91804
56396/91804
56442/91804
545/91804
1287/91804
2311/91804
2584/91804
507/91804
845/91804
4/91804
Unzip succeeded
Can someone help me ?

It is because you use length of compressed zipFile as the maximum, and the count of bytes raeded from each uncompressed zipEntry as the postion - the size of compressed file is in most cases different from the uncompressed one, also you can have multiple files in the zip package - so the progres will jump from 0 to some value (the size of actual zipEntry not the compressed zipFile length) for each one in this case. To have the actual position in a zip file, get the reference to FileChannel from the FileInputStream, using this method: FileInputStream#getChannel();
then when it comes to update the progres do:
updateProgress(channel.position(), length);
This will update the progress bar according to the actual position that was readed in the zipFile (not the size of uncompressed content).
It could be something like:
package com.franckyi.lan.installer;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import javafx.concurrent.Task;
public class UnZipTask extends Task<Void>{
private File zipfile;
private File folder;
public UnZipTask(File zipfile, File folder){
this.zipfile = zipfile;
this.folder = folder;
}
#Override
protected Void call() throws Exception {
FileInputStream is = new FileInputStream(zipfile.getCanonicalFile());
FileChannel channel = is.getChannel();
ZipInputStream zis = new ZipInputStream(new BufferedInputStream(is));
ZipEntry ze = null;
try {
while ((ze = zis.getNextEntry()) != null) {
File f = new File(folder.getCanonicalPath(), ze.getName());
if (ze.isDirectory()) {
f.mkdirs();
continue;
}
f.getParentFile().mkdirs();
OutputStream fos = new BufferedOutputStream(new FileOutputStream(f));
try {
try {
final byte[] buf = new byte[1024];
int bytesRead;
long nread = 0L;
long length = zipfile.length();
while (-1 != (bytesRead = zis.read(buf))){
fos.write(buf, 0, bytesRead);
nread += bytesRead;
System.out.println(nread + "/" + length);
updateProgress(channel.position(), length);
}
} finally {
fos.close();
}
} catch (final IOException ioe) {
f.delete();
throw ioe;
}
}
} finally {
zis.close();
}
return null;
}
#Override
protected void succeeded(){
System.out.println("Unzip succeeded");
}
}

Related

I'm trying to lock file exclusively on read

I'm trying to lock a file exclusively on read.
I am using Java 7 on Windows 7.
The files are copied to a directory, and then I want to to read them correctly after copy. That's why I'm trying lock file exclusively on read.
But my program read file in the middle.
Can anyone please help me with this? Thanks!
package test;
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Files;
public class FileLockMove {
public static void main(String[] args) {
FileSystem fs = FileSystems.getDefault();
File dir = new File("c:/test_source/");
while(true){
for (File file : dir.listFiles()) {
try (FileChannel fc = (new RandomAccessFile(file, "rw")).getChannel()){
FileLock lock = fc.tryLock();
if(lock != null){
System.out.println("lock is not null\t" + file.getName());
System.out.println("addBody: " + file.getAbsolutePath() + "\t" + file.length());
}else{
System.out.println("lock is null\t" + file.getName());
continue;
}
} catch (Exception e) {
System.out.println("fail:" + file.getName()+"\t" + e.getMessage());
}
try {
Files.move(file.toPath(), fs.getPath("c:/test_dest/",file.getName()));
} catch (IOException e) {
e.printStackTrace();
}
}
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
Originally, the copy file is not Java, but I created a copy of my program slowly to confirm that I can lock exclusively.
package test;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FilenameFilter;
public class FileCopySlow{
public static void main(String[] args) {
String source = "C:/test_orig/";
String dst ="C:/test_source/";
File file = new File(source);
File[] files = file.listFiles(new FilenameFilter() {
#Override
public boolean accept(File dir, String name) {
if(name.matches(".*\\.bmp")){
return true;
}
return false;
}
});
for(File f: files){
copyStream(f, dst);
}
}
static void copyStream(File source,String dst){
try(BufferedInputStream br = new BufferedInputStream(new FileInputStream(source))){
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(dst+source.getName()));
byte[] buff = new byte[100];
int len = -1;
while((len = br.read(buff)) >-1){
out.write(buff,0,len);
out.flush();
Thread.sleep(100);
}
out.close();
System.out.println(source.getName() + "\tfinish");
}catch(Exception e){
e.printStackTrace();
}
}
}

unzipping files in /data/data/ folder - Android Java Programming

How would I programmatically unzip backed up data directly into a /data/data/com.appname folder from the SD Card?
I am able to directly unzip folders in the /data/data/com.appname folder using ES File Explorer, however I need to automate this via the app I'm developing.
I've tried the following code, Unfortunately I am only able to unzip to the SD Card and data folder of my app.
I'm guessing this is due to some form of app/folder security?
MainActivity.java
package fb.ziptester;
import android.provider.Settings;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void buttonOnClick(View v) {
TextView zipSource = (TextView)findViewById(R.id.zip_source);
TextView zipDest = (TextView)findViewById(R.id.zip_dest);
String sZipSource = "/storage/sdcard1/ACC/BU.zip";
String sZipDest = "/data/data/com.appname/";
zipSource.setText(sZipSource);
zipDest.setText(sZipDest);
UnzipUtility zipUtil = new UnzipUtility();
try {
zipUtil.unzip(sZipSource, sZipDest);
} catch(Exception ex) {
//TODO
}
}
}
package fb.ziptester;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
UnzipUtility.java
public class UnzipUtility {
/**
* Size of the buffer to read/write data
*/
private static final int BUFFER_SIZE = 4096;
/**
* Extracts a zip file specified by the zipFilePath to a directory specified by
* destDirectory (will be created if does not exists)
* #param zipFilePath
* #param destDirectory
* #throws IOException
*/
public void unzip(String zipFilePath, String destDirectory) throws IOException {
File destDir = new File(destDirectory);
if (!destDir.exists()) {
destDir.mkdir();
}
ZipInputStream zipIn = new ZipInputStream(new FileInputStream(zipFilePath));
ZipEntry entry = zipIn.getNextEntry();
// iterates over entries in the zip file
while (entry != null) {
String filePath = destDirectory + File.separator + entry.getName();
if (!entry.isDirectory()) {
// if the entry is a file, extracts it
extractFile(zipIn, filePath);
} else {
// if the entry is a directory, make the directory
File dir = new File(filePath);
dir.mkdir();
}
zipIn.closeEntry();
entry = zipIn.getNextEntry();
}
zipIn.close();
}
/**
* Extracts a zip entry (file entry)
* #param zipIn
* #param filePath
* #throws IOException
*/
private void extractFile(ZipInputStream zipIn, String filePath) throws IOException {
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(filePath));
byte[] bytesIn = new byte[BUFFER_SIZE];
int read = 0;
while ((read = zipIn.read(bytesIn)) != -1) {
bos.write(bytesIn, 0, read);
}
bos.close();
}
}
Any help would be much appreciated.
Thank you.

Java - how to print the PDF to a specific printer?

I have 5 printers in Windows 8.1 and the PDF file is not in local system its generated in PHP server.
Question. how can i get the PDF file from the server and print to a specific printer?
I am trying with Apache PDFBox 2.0.0
EDIT:
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import javax.print.DocPrintJob;
import javax.print.PrintService;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.printing.PDFPageable;
public class JPrint {
public static boolean saveFile(URL url, String file) throws IOException {
boolean download_status = false;
System.out.println("[OK] - open");
InputStream in = url.openStream();
FileOutputStream fos = new FileOutputStream(new File(file));
System.out.println("[OK] - reading file...");
int length = -1;
byte[] buffer = new byte[1024];
while ((length = in.read(buffer)) > -1) {
fos.write(buffer, 0, length);
}
fos.close();
in.close();
download_status = true;
System.out.println("[OK] - downloaded");
return download_status;
}
public static void main(String[] args) throws IOException, PrinterException {
String downloaded_filename = "C:/Users/tpt/Downloads/pdf.pdf";
String download_pdf_from = "https://github.com/msysgit/msysgit/releases/download/Git-1.9.2-preview20140411/Git-1.9.2-preview20140411.exe";
String downloaded_filename_open_as_pdf = "C:\\Users\\tpt\\Downloads\\pdf.pdf";
String printerNameDesired = "DYMO LabelWriter 450"; // Brother HL-6180DW series
// Get printers
PrintService[] services = PrinterJob.lookupPrintServices();
DocPrintJob docPrintJob = null;
try{
URL url = new URL(download_pdf_from);
if(saveFile(url, downloaded_filename)) {
try {
PDDocument pdf = PDDocument.load(new File(downloaded_filename_open_as_pdf));
PrinterJob job = PrinterJob.getPrinterJob();
for (int i = 0; i < services.length; i++) {
if (services[i].getName().equalsIgnoreCase(printerNameDesired)) {
docPrintJob = services[i].createPrintJob();
}
}
job.setPrintService(docPrintJob.getPrintService());
job.setPageable(new PDFPageable(pdf));
//docPrintJob = service[i].createPrintJob();
job.print();
} catch (Exception e) {
System.out.println("[FAIL]" + e);
}
} else {
System.out.println("[FAIL] - download fail");
}
} catch (Exception ae) {
System.out.println("[FAIL]" + ae);
}
}
}
This gives you back a list of available printers:
PrintService[] services = PrinterJob.lookupPrintServices();
You can loop through this array and select the printer by name (services[i].getName())

java - FTPClient, multithread upload doesn't work.

I am making an application that let's you upload up to 5 files at once to server. I am using apache FTPClient and Filezilla server. when I upload one file at a time it works but when I try to get 2 or more uploads going I get socket exception, the first file that was uploading stops and the new one starts. Here's my UploadThread class:
package uploaduptofive;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import org.apache.commons.net.ftp.FTPClient;
public class ThreadUpload implements Runnable {
FileInputStream inputStream;
long fileLength;
File selFile;
JFrameClass jFrame;
static String fajl;
FTPClient ftpClient;
String ime;
long progress = 0;
int i;
public ThreadUpload(JFrameClass jFrame, FTPClient ftpClient) {
this.jFrame = jFrame;
this.ftpClient = ftpClient;
}
#Override
public synchronized void run() {
i = jFrame.i;
JFileChooser fc = new JFileChooser();
fc.setDialogTitle("Upload file");
fc.setAcceptAllFileFilterUsed(true);
if (fc.showOpenDialog(jFrame) == JFileChooser.APPROVE_OPTION) {
selFile = fc.getSelectedFile();
System.out.println(selFile.length());
Path path = Paths.get(selFile.toString());
fileLength = selFile.length();
fajl = selFile.toString();
ime = selFile.getName();
System.out.println(ime);
try {
upload();
} catch (FileNotFoundException ex) {
Logger.getLogger(ThreadUpload.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(ThreadUpload.class.getName()).log(Level.SEVERE, null, ex);
}
} else {
jFrame.indeksProgress[jFrame.i] = -1;
}
}
protected void upload() throws FileNotFoundException, IOException {
File secondLocalFile = new File(fajl);
String secondRemoteFile = ime;
inputStream = new FileInputStream(secondLocalFile);
OutputStream outputStream = ftpClient.storeFileStream(secondRemoteFile);
byte[] bytesIn = new byte[4096];
int read = 0;
jFrame.nizProgress.get(jFrame.indeksProgress[i]).setValue(0);
while ((read = inputStream.read(bytesIn)) != -1) {
outputStream.write(bytesIn, 0, read);
progress = progress + 4096;
System.out.println("" + ((progress * 100 / fileLength)));
jFrame.nizProgress.get(jFrame.indeksProgress[i]).setValue((int) ((progress * 100 / fileLength)));
}
System.out.println("" + ((((progress) / fileLength) * 100)));
jFrame.nizProgress.get(jFrame.indeksProgress[i]).setValue(100);
inputStream.close();
outputStream.close();
boolean completed = ftpClient.completePendingCommand();
if (completed) {
System.out.println("Uploaded!");
}
}
}
I run threads from class name JFrameClass:
Runnable run = new ThreadUpload(JFrameClass.this, ftpClient);
new Thread(run).start();
here is the error I get:
mar 07, 2013 4:39:01 PM uploaduptofive.ThreadUpload run
SEVERE: null
java.net.SocketException: Software caused connection abort: socket write error
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
at org.apache.commons.net.io.SocketOutputStream.write(SocketOutputStream.java:71)
at uploaduptofive.ThreadUpload.upload(ThreadUpload.java:79)
at uploaduptofive.ThreadUpload.run(ThreadUpload.java:57)
at java.lang.Thread.run(Thread.java:722)
ThreadUpload.java:57 is where upload(); is, and (ThreadUpload.java:79) is where outputStream.write(bytesIn, 0, read); is.
Apparently, you use the same FtpClient for the two upload processes.
You should re-instantiate a new FtpClient to open a new socket and allow several files being downloaded at the same time:
FtpClient ftpClient = new FtpClient() ;
...
//Opens a new socket
ftpClient.connect("ftp.example.com");
...
Runnable run = new ThreadUpload(JFrameClass.this, ftpClient);
new Thread(run).start();

How to unzip a zip folder containing different file formats using Java

I need to unzip a zipped directory containing different files' format like .txt, .xml, .xls etc.
I am able to unzip if the directory contains only .txt files but it fails with other files format. Below is the program that I am using and after a bit of googling, all I saw was similar approach -
import java.io.*;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
public class ZipUtils {
public static void extractFile(InputStream inStream, OutputStream outStream) throws IOException {
byte[] buf = new byte[1024];
int l;
while ((l = inStream.read(buf)) >= 0) {
outStream.write(buf, 0, l);
}
inStream.close();
outStream.close();
}
public static void main(String[] args) {
Enumeration enumEntries;
ZipFile zip;
try {
zip = new ZipFile("myzip.zip");
enumEntries = zip.entries();
while (enumEntries.hasMoreElements()) {
ZipEntry zipentry = (ZipEntry) enumEntries.nextElement();
if (zipentry.isDirectory()) {
System.out.println("Name of Extract directory : " + zipentry.getName());
(new File(zipentry.getName())).mkdir();
continue;
}
System.out.println("Name of Extract fille : " + zipentry.getName());
extractFile(zip.getInputStream(zipentry), new FileOutputStream(zipentry.getName()));
}
zip.close();
} catch (IOException ioe) {
System.out.println("There is an IoException Occured :" + ioe);
ioe.printStackTrace();
}
}
}
Throws the below exception -
There is an IoException Occured :java.io.FileNotFoundException: myzip\abc.xml (The system cannot find the path specified)
java.io.FileNotFoundException: myzip\abc.xml (The system cannot find the path specified)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:212)
at java.io.FileOutputStream.<init>(FileOutputStream.java:104)
at updaterunresults.ZipUtils.main(ZipUtils.java:43)
When you try to open the file that is going to contain the extracted content, the error occurs.
This is because the myzip folder is not available.
So check if it indeed is not available and create it before extracting the zip:
File outputDirectory = new File("myzip");
if(!outputDirectory.exists()){
outputDirectory.mkdir();
}
As #Perception pointed out in the comments: The output location is relative to the active/working directory. This is probably not very convenient, so you might want to add the extraction location to the location of the extracted files:
File outputLocation = new File(outputDirectory, zipentry.getName());
extractFile(zip.getInputStream(zipentry), new FileOutputStream(outputLocation));
(of course you need also add outputLocation to the directory creation code)
This is a good example in which he showed to unzip all the formats (pdf, txt etc) have look its quite
or you can use this code might work (i haven't tried this)
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
public class ZipUtils
{
private static final int BUFFER_SIZE = 4096;
private static void extractFile(ZipInputStream in, File outdir, String name) throws IOException
{
byte[] buffer = new byte[BUFFER_SIZE];
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(new File(outdir,name)));
int count = -1;
while ((count = in.read(buffer)) != -1)
out.write(buffer, 0, count);
out.close();
}
private static void mkdirs(File outdir,String path)
{
File d = new File(outdir, path);
if( !d.exists() )
d.mkdirs();
}
private static String dirpart(String name)
{
int s = name.lastIndexOf( File.separatorChar );
return s == -1 ? null : name.substring( 0, s );
}
/***
* Extract zipfile to outdir with complete directory structure
* #param zipfile Input .zip file
* #param outdir Output directory
*/
public static void extract(File zipfile, File outdir)
{
try
{
ZipInputStream zin = new ZipInputStream(new FileInputStream(zipfile));
ZipEntry entry;
String name, dir;
while ((entry = zin.getNextEntry()) != null)
{
name = entry.getName();
if( entry.isDirectory() )
{
mkdirs(outdir,name);
continue;
}
/* this part is necessary because file entry can come before
* directory entry where is file located
* i.e.:
* /foo/foo.txt
* /foo/
*/
dir = dirpart(name);
if( dir != null )
mkdirs(outdir,dir);
extractFile(zin, outdir, name);
}
zin.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
Regards

Categories

Resources