import java.io.*; import java.util.*; /*------------------------------- how to: java ImageCopyNo2 t.txt abcde --------------------------------*/ public class ImageCopyNo2 { 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; 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; Vector vc = fileRead ( args[0] ); for ( int i = 0; i < vc.size(); i++) { if ( vc.elementAt(i).toString().substring(0,1).equals("Q") || vc.elementAt(i).toString().substring(0,1).equals("U") ) { iPath = "/www/images/prdimg/"+vc.elementAt(i).toString().substring(0,1)+"/"; } else { iPath = "/www/images/prdimg/"+vc.elementAt(i).toString().substring(0,1)+"/"; } if ( isA ) { if ( isFileExit ( iPath + vc.elementAt(i).toString() + "_a.gif" ) ) { /* bCopy( iPath + vc.elementAt(i).toString(), tPath + vc.elementAt(i).toString(), "_a.gif" ); */ } else { bCopy( "/www/images/UAcommon/noimage", tPath + vc.elementAt(i).toString(), "_a.gif" ); } } if ( isB ) { if ( isFileExit ( iPath + vc.elementAt(i).toString() + "_b.gif" ) ) { bCopy( iPath + vc.elementAt(i).toString(), tPath + vc.elementAt(i).toString(), "_b.gif" ); } else { } } if ( isC ) { if ( isFileExit ( iPath + vc.elementAt(i).toString() + "_c.gif" ) ) { /* bCopy( iPath + vc.elementAt(i).toString(), tPath + vc.elementAt(i).toString(), "_c.gif" ); */ } else { bCopy( "/www/images/UAcommon/noimage", tPath + vc.elementAt(i).toString(), "_c.gif" ); } } if ( isD ) { if ( isFileExit ( iPath + vc.elementAt(i).toString() + "_d.gif" ) ) { /* bCopy( iPath + vc.elementAt(i).toString(), tPath + vc.elementAt(i).toString(), "_d.gif" );*/ } else { bCopy( "/www/images/UAcommon/noimage", tPath + vc.elementAt(i).toString(), "_d.gif" ); } } if ( isE ) { if ( isFileExit ( iPath + vc.elementAt(i).toString() + "_e.gif" ) ) { bCopy( iPath + vc.elementAt(i).toString(), tPath + vc.elementAt(i).toString(), "_e.gif" ); } else { } } } } 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(); } public static boolean isFileExit( String fileName ) { File f = new File( fileName ); return f.exists() ; } }