Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Thread Tools Search this Thread
Old 07-04-2009
Join Date: Mar 2009
Posts: 3
idea Search inside executable jar copy files out ResourceAsStream

i have ben working on this for a vary long time can some one heeellllp me i have tryd 100ds of whays it just dosent work heres my search and copy code

import java.io.*;import java.util.*;
public class search_and_copy
{int a=0,b=0,s=0;String path="copy";
BufferedInputStream in=null;
BufferedOutputStream out=null;
Vector files=new Vector();
Vector folders=new Vector();
public static void main(String[] args)
{new search_and_copy();}
public search_and_copy(){try{start();}catch(IOException e){}}
public void start()throws IOException
{File folder=new File(path);
File[] listOfFiles=folder.listFiles();
for(int i=0;i<listOfFiles.length;i++)
else if(listOfFiles[i].isDirectory())
public void Write()
{System.out.println("Directorys "+b);
for(int j=0;j<folders.size();++j)
{new File("copy to/"+folders.elementAt(j).toString()).mkdirs();
System.out.println("Dir Created: copy to/"+folders.elementAt(j));}
System.out.println("files "+a);
for(int j=0;j<files.size();++j)
{try{in=new BufferedInputStream(new FileInputStream(files.elementAt(j).toString()));
File outFile=new File("copy to/"+files.elementAt(j).toString());
out=new BufferedOutputStream(new FileOutputStream(outFile));
long totalBytes=in.available();int r;
long bytesRead=0;byte[] b=new byte[20];
catch(FileNotFoundException ex){}
catch(Exception ex){}}
System.out.println("File Copyd to: copy to/"+files.elementAt(j));}
System.out.println("Folder copyd");}}

if you can get this to work in jar ill be vary happy
the idea is no mater how much you add to the jar it self extracts
Reply With Quote
Old 07-04-2009
Join Date: Mar 2009
Posts: 3
star Re: search inside executable jar copy files out ResourceAsStream

heres the full code

import java.io.*;import java.io.*;
public class ex_jar
{public static void main(String[]args)
{try{new ex_jar();}catch(IOException e){}catch(Exception e){}}
public ex_jar()throws IOException,Exception
{java.net.URL outputURL=ex_jar.class.getProtectionDomain().getCodeSource().getLocation();
String outputString=outputURL.toString();
String[] parseString;
int index1=outputString.indexOf(":");
int index2=outputString.lastIndexOf(":");
String jarFilename=parseString[1];
java.util.jar.JarFile jf=new java.util.jar.JarFile(jarFilename);
java.util.Enumeration resources=jf.entries();
{java.util.jar.JarEntry je=(java.util.jar.JarEntry)resources.nextElement();
{new File(je.getName().toString()).mkdirs();}
else if(!je.getName().matches(".*/")&&!je.getName().matches("ex_jar.class")&&!je.getName().matches("META-INF/MANIFEST.MF"))
{BufferedInputStream in=new BufferedInputStream(ex_jar.class.getResourceAsStream(je.getName().toString()));
File outFile=new File(je.getName().toString());
BufferedOutputStream out=new BufferedOutputStream(new FileOutputStream(outFile));
byte[] b=new byte[20];int r;
if(out!=null){out.close();}}}}}java program by damian any one can edit if you wont or you make it bater but repost the coad so i can see how it works or if its bater think you to hoo ever

dose repost

Last edited by =[HACK]=Ч : 07-04-2009 at 10:47 PM.
Reply With Quote

  TechArena Community > Software > Software Development
Tags: , ,

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Similar Threads for: "Search inside executable jar copy files out ResourceAsStream"
Thread Thread Starter Forum Replies Last Post
How to select or search multiple files and copy and paste it to new folder in windows 7 Buddha Anand Operating Systems 4 17-05-2012 06:37 AM
Opening UNIX Executable Files in the OS X Mithras Operating Systems 6 15-11-2010 08:52 AM
Files on Server display as UNIX Executable Files Maia Operating Systems 6 12-11-2010 07:40 AM
Running executable files in Linux Benjhonson Operating Systems 5 10-11-2010 12:10 PM
How to Send Out Executable Files Via Gmail mauricio Tips & Tweaks 0 14-06-2008 02:22 AM

All times are GMT +5.5. The time now is 03:28 AM.