import java.io.*; import java.util.*; /*------------------------------- how to: java ImageCopy t.txt abcde --------------------------------*/ public class ImageCopy { static Runtime r = Runtime.getRuntime(); public static void main ( String args[] ) { String iPath = ""; String tPath = "/www/images/copy/"; String iV = args[1]; boolean isA = false; boolean isB = false; boolean isC = false; boolean isD = false; boolean isE = false; boolean isF = false; if ( iV.indexOf("a") >= 0 ) isA = true; if ( iV.indexOf("b") >= 0 ) isB = true; if ( iV.indexOf("c") >= 0 ) isC = true; if ( iV.indexOf("d") >= 0 ) isD = true; if ( iV.indexOf("e") >= 0 ) isE = true; if ( iV.indexOf("f") >= 0 ) isF = true; Vector vc = fileRead ( args[0] ); for ( int i = 0; i < vc.size(); i++) { iPath = "/www/images/prdimg/"+vc.elementAt(i).toString().substring(0,1)+"/"+vc.elementAt(i).toString().substring(0,2)+"/"+vc.elementAt(i).toString().substring(0,3)+"/"; if ( isA ) { bCopy( iPath + vc.elementAt(i).toString(), tPath + vc.elementAt(i).toString(), "_a.gif" ); } if ( isB ) { bCopy( iPath + vc.elementAt(i).toString(), tPath + vc.elementAt(i).toString(), "_b.gif" ); } if ( isC ) { bCopy( iPath + vc.elementAt(i).toString(), tPath + vc.elementAt(i).toString(), "_c.gif" ); } if ( isD ) { bCopy( iPath + vc.elementAt(i).toString(), tPath + vc.elementAt(i).toString(), "_d.gif" ); } if ( isE ) { bCopy( iPath + vc.elementAt(i).toString(), tPath + vc.elementAt(i).toString(), "_e.gif" ); } if ( isF ) { bCopy( iPath + vc.elementAt(i).toString(), tPath + vc.elementAt(i).toString(), "_f.gif" ); } } } public static Vector fileRead( String fileName ) { Vector vcF = new Vector(); try { BufferedReader in = new BufferedReader( new FileReader(fileName) ); String temp = null; while((temp = in.readLine()) !=null){ vcF.addElement( temp ); } return vcF ; } catch(IOException e){ e.printStackTrace(); return vcF ; } } public static void bCopy ( String a, String b, String c) { try { copy ( a+c, b+c ); } catch(IOException e) { System.out.println ( e); } } public static void copy ( String a, String b ) throws IOException { System.out.println("copy: " + a); r.exec("cp "+ a + " " + b ); r.gc(); } }