Вам нужно просмотреть каждую запись загрузчика класса в пути к классу:
String pkg = "org/apache/commons/lang";
ClassLoader cl = ClassLoader.getSystemClassLoader();
URL[] urls = ((URLClassLoader) cl).getURLs();
for (URL url : urls) {
System.out.println(url.getFile());
File jar = new File(url.getFile());
// ....
}
Если запись является каталогом, просто посмотрите в правый подкаталог:
if (jar.isDirectory()) {
File subdir = new File(jar, pkg);
if (!subdir.exists())
continue;
File[] files = subdir.listFiles();
for (File file : files) {
if (!file.isFile())
continue;
if (file.getName().endsWith(".class"))
System.out.println("Found class: "
+ file.getName().substring(0,
file.getName().length() - 6));
}
}
Если запись является файлом, и это jar, проверьте записи ZIP:
else {
// try to open as ZIP
try {
ZipFile zip = new ZipFile(jar);
for (Enumeration<? extends ZipEntry> entries = zip
.entries(); entries.hasMoreElements();) {
ZipEntry entry = entries.nextElement();
String name = entry.getName();
if (!name.startsWith(pkg))
continue;
name = name.substring(pkg.length() + 1);
if (name.indexOf('/') < 0 && name.endsWith(".class"))
System.out.println("Found class: "
+ name.substring(0, name.length() - 6));
}
} catch (ZipException e) {
System.out.println("Not a ZIP: " + e.getMessage());
} catch (IOException e) {
System.err.println(e.getMessage());
}
}
Теперь, когда у вас есть все имена классов с пакетом, вы можете попробовать их загрузить и проанализировать, если они классы или интерфейсы и т. д.
Если нет сценарий, где Вы были бы не , хотят скопировать существующие файлы в источнике, которые изменились начиная с последней копии, почему бы не использовать XCOPY с/D, не определяя дату?
Можно сделать текстовый файл с одной длинной строкой "n", затем выполнить команду и поставить после нее < nc.txt. Я сделал это, чтобы скопировать более 145 000 экземпляров, где "No overwrite" - это то, что я хотел, и это отлично сработало.
Или вы можете просто удерживать клавишу n нажатой чем-нибудь, но это займет больше времени, чем использование команды <, чтобы вставить ее внутрь.
Вот обходное решение. Если Вы хотите скопировать все с, который уже не существует в B:
Копия к новому каталогу C. Скопируйте B в C, перезаписав что-либо, что накладывается с A. Скопируйте C в B.
Я использую XCOPY
со следующими параметрами для копирования блоков.NET:
/D /Y /R /H
/D:m-d-y - Copies files changed on or after the specified date. If no date is given, copies only those files whose source time is newer than the destination time.
/Y - Suppresses prompting to confirm you want to overwrite an existing destination file.
/R - Overwrites read-only files.
/H - Copies hidden and system files also.
Я ожидаю , xcopy имеет опция для этого.
Бинго:
http://www.xxcopy.com/xxcopy27.htm#tag_231
2.3 By comparison with the file in destination
The switches in this group select files based on the
comparison between the files in the source and those in
the destination. They are often used for periodic backup
and directory synchronization purposes. These switches
were originally created as variations of directory backup.
They are also convenient for selecting files for deletion.
2.3.1 by Presence/Absence
The /BB and /U switches are the two switches which select
files by the pure presence or absence as the criteria.
Other switches in the this group (Group 2.3) are also
affected by the file in the destination, but for a
particular characteristics for comparison's sake.
/BB Selects files that are present in source but not in destination.
/U Selects files that are present in both source and destination.
-Adam
В зависимости от размера и количества скопированных файлов, Вы могли скопировать целевой каталог по источнику сначала с "да ко всем", тогда сделайте оригинал, который Вы делали, также с "да ко всему" набору. Это должно дать Вам те же результаты.