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++)
{if(listOfFiles[i].isFile())
{a=a+1;files.add(listOfFiles[i].toString());}
else if(listOfFiles[i].isDirectory())
{b=b+1;folders.add(listOfFiles[i].toString());}}
if(s==b){Write();}else{path=folders.elementAt(s).toString();s=s+1;start();}}
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];
while((r=in.read(b,0,b.length))!=-1)
{out.write(b,0,r);bytesRead+=r;}}
catch(FileNotFoundException ex){}
finally{try{if(in!=null)in.close();
if(out!=null)out.close();}
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
Bookmarks