• R/O
  • SSH

提交

標籤
無標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#objective-cqt誰得cocoawindowspythonphprubygameguibathyscaphec翻訳omegat計画中(planning stage)frameworktwittertestdombtronvb.netdirectxarduinopreviewerゲームエンジン

Gradle/Mavenが持っているjarファイルのパスを表示するツール


Commit MetaInfo

修訂da961ec46cb2be86605ce97cbbb89ab1be284056 (tree)
時間2022-04-10 07:19:04
作者kemono7h
Commiterkemono7h

Log Message

classファイルを持たないjarをグレー色で表示するようにした

Change Summary

差異

diff -r 500769e40e5a -r da961ec46cb2 src/jp/nanah/dnj/DokonanJarMain.java
--- a/src/jp/nanah/dnj/DokonanJarMain.java Sat Apr 09 07:02:39 2022 +0900
+++ b/src/jp/nanah/dnj/DokonanJarMain.java Sun Apr 10 07:19:04 2022 +0900
@@ -18,6 +18,7 @@
1818 import javax.swing.event.HyperlinkListener;
1919
2020 import jp.nanah.dnj.util.FileUtils;
21+import jp.nanah.dnj.util.JarUtils;
2122
2223 public class DokonanJarMain {
2324
@@ -203,7 +204,15 @@
203204 for (int i=0; i<texts.length; i++) {
204205 dispname = dispname.replaceAll(texts[i], "<b>"+texts[i]+"</b>");
205206 }
206- return beforeLastFolder + "<a href='file:" + fullpath + "'>" + dispname + ".jar</a>";
207+ String html_line = beforeLastFolder + "<a href='file:" + fullpath + "'>" + dispname + ".jar</a>";
208+
209+ if (file.length() < 10000) {
210+ boolean hasClass = JarUtils.hasDotClass(file);
211+ if (hasClass == false) {
212+ html_line = "<font color='silver'>" + html_line + "(※no-class)</font>";
213+ }
214+ }
215+ return html_line;
207216 }
208217
209218 private String[] getSearchTexts(String path) {
diff -r 500769e40e5a -r da961ec46cb2 src/jp/nanah/dnj/util/JarUtils.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jp/nanah/dnj/util/JarUtils.java Sun Apr 10 07:19:04 2022 +0900
@@ -0,0 +1,56 @@
1+package jp.nanah.dnj.util;
2+
3+import java.io.File;
4+import java.io.FileInputStream;
5+import java.io.IOException;
6+import java.util.zip.ZipEntry;
7+import java.util.zip.ZipInputStream;
8+
9+public class JarUtils {
10+
11+ //---------------------------------------------
12+ // Jar一覧を取得
13+ //---------------------------------------------
14+
15+ public static boolean hasDotClass(File file){
16+ ZipInputStream zistr = null;
17+ try {
18+ zistr = new ZipInputStream(new FileInputStream(file));
19+ ZipEntry zipEntry = null;
20+
21+ while ((zipEntry = zistr.getNextEntry()) != null) {
22+ String name = zipEntry.getName();
23+ System.out.println(name);
24+ if (name.endsWith(".class")) {
25+ return true;
26+ }
27+ //classList
28+// File uncompressFile = new File(zipEntry.getName());
29+// System.out.println("");
30+ //
31+// if (zipEntry.isDirectory()) {
32+// uncompressFile.mkdirs();
33+// } else {
34+// BufferedOutputStream bostr = new BufferedOutputStream(new FileOutputStream(uncompressFile));
35+// while ((len = zistr.read(buf)) != -1) {
36+// bostr.write(buf, 0, len);
37+// }
38+// bostr.close();
39+// }
40+ }
41+ } catch (IOException ex) {
42+ ex.printStackTrace();
43+ } finally {
44+ try {
45+ if (zistr != null) {
46+ zistr.close();
47+ }
48+ } catch (Throwable th) {
49+
50+ }
51+ }
52+
53+ return false;
54+ }
55+
56+}