Java FileInputStream Read loadFolderFromJar(String path)

Here you can find the source of loadFolderFromJar(String path)

Description

load Folder From Jar

License

Open Source License

Declaration

public static void loadFolderFromJar(String path) throws Exception 

Method Source Code


//package com.java2s;
import java.io.*;

public class Main {
    public static void loadFolderFromJar(String path) throws Exception {
        InputStream in = null;/*from w  w  w. j  a  va 2s  . c o  m*/
        FileOutputStream fos = null;

        try {
            File dir = new File(path);
            for (File nextFile : dir.listFiles()) {
                in = new FileInputStream(nextFile.toString());

                File temp = new File("cdatafiles" + File.separator + nextFile.getName());
                temp.getParentFile().mkdirs();
                temp.createNewFile();
                fos = new FileOutputStream(temp);

                byte[] buffer = new byte[1024];
                int read = -1;

                while ((read = in.read(buffer)) != -1)
                    fos.write(buffer, 0, read);
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (fos != null)
                fos.close();
            if (in != null)
                in.close();
        }
    }
}

Related

  1. load(File file)
  2. load(File file)
  3. load(String file)
  4. loadContents(File file)
  5. loadData(File f)
  6. loadRes(String res)
  7. loadStackableItems(String fileName)
  8. loadTxtFile(String fileName)
  9. readFile( String filename)