由于jar命令去查找class文件速度比较慢,我个人尝试使用7z.exe,7z.dll,结合批处理,效果非常不错。
请看示例:
for %i in (dir/b/s *.jar) do 7z l %i | findstr XDatabase.class
结果:
-
D:\shared\xsql>for %i in (dir/b/s *.jar) do 7z l %i |findstr XDatabase.class
-
-
D:\shared\xsql>7z l dir/b/s | findstr XDatabase.class
-
-
D:\shared\xsql>7z l db2jcc.jar | findstr XDatabase.class
-
-
D:\shared\xsql>7z l db2jcc_license_cu.jar | findstr XDatabase.class
-
-
D:\shared\xsql>7z l jconn3.jar | findstr XDatabase.class
-
-
D:\shared\xsql>7z l jodbc.jar | findstr XDatabase.class
-
-
D:\shared\xsql>7z l jTDS3.jar | findstr XDatabase.class
-
-
D:\shared\xsql>7z l mlscript.jar | findstr XDatabase.class
-
-
D:\shared\xsql>7z l msbase.jar | findstr XDatabase.class
-
-
D:\shared\xsql>7z l mssqlserver.jar | findstr XDatabase.class
-
-
D:\shared\xsql>7z l msutil.jar | findstr XDatabase.class
-
-
D:\shared\xsql>7z l mysql-connector-java-5.1.6-bin.jar | findstr XDatabase.class
-
-
D:\shared\xsql>7z l ojdbc14.jar | findstr XDatabase.class
-
-
D:\shared\xsql>7z l postgresql-8.4-701.jdbc4.jar | findstr XDatabase.class
-
-
D:\shared\xsql>7z l sqlite.jar | findstr XDatabase.class
-
-
D:\shared\xsql>7z l sqlitejdbc-v056-zentus.jar | findstr XDatabase.class
-
-
D:\shared\xsql>7z l sqljdbc.jar | findstr XDatabase.class
-
-
D:\shared\xsql>7z l ULjDatabaseTransfer.jar | findstr XDatabase.class
-
-
D:\shared\xsql>7z l UltraLiteJ.jar | findstr XDatabase.class
-
-
D:\shared\xsql>7z l UltraLiteJ12.jar | findstr XDatabase.class
-
-
[b]D:\shared\xsql>7z l xsql.jar | findstr XDatabase.class
-
2010-12-24 21:05:40 ..... 30863 14443 [/b]com\sean\db\XDatabase.class
最末一行展示的是最终结果。
将上述逻辑写成批处理:
-
@echo off
-
SETLOCAL
-
-
set WHICH_CLASS=%1
-
echo WHICH_CLASS=%WHICH_CLASS%
-
-
for /F %%i in ('dir /A:-D /S /B *.jar') do 7z l %%i | findstr %WHICH_CLASS% && echo %WHICH_CLASS% found in: "%%i"
-
echo "Finished class finding..."
-
echo "======================================"
-
ENDLOCAL
运行一下命令:
-
findclass com\\sybase\\afx\\util\\StringUtil.class
-
WHICH_CLASS=com\\sybase\\afx\\util\\StringUtil.class
-
2012-02-27 13:14:36 ..... 15230 5915 com\sybase\afx\util\StringUtil.class
-
com\\sybase\\afx\\util\\StringUtil.class found in: "U:\target\lib\ext\sup-client.jar"
-
2012-02-27 13:14:36 ..... 15230 5915 com\sybase\afx\util\StringUtil.class
-
com\\sybase\\afx\\util\\StringUtil.class found in: "U:\target\lib\ext\sup-server-rt.jar"
-
"Finished class finding..."
-
"======================================"
findclass com\\sybase\\afx\\util\\StringUtil.class
WHICH_CLASS=com\\sybase\\afx\\util\\StringUtil.class
2012-02-27 13:14:36 ..... 15230 5915 com\sybase\afx\util\StringUtil.class
com\\sybase\\afx\\util\\StringUtil.class found in: "U:\target\lib\ext\sup-client.jar"
2012-02-27 13:14:36 ..... 15230 5915 com\sybase\afx\util\StringUtil.class
com\\sybase\\afx\\util\\StringUtil.class found in: "U:\target\lib\ext\sup-server-rt.jar"
"Finished class finding..."
"======================================"
很容易得到最终结果。如果时间充分,我们甚至可以修改7z的源码,让它直接列出文件的全路径,那样,直接使用7z就可以找到最终文件了。
阅读(1956) | 评论(0) | 转发(0) |