Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions src/main/java/core/packetproxy/PacketProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
package packetproxy;

import java.io.File;
import java.io.InputStream;
import java.sql.SQLException;
import javax.swing.*;
import org.apache.commons.io.IOUtils;
import packetproxy.common.AppVersion;
import packetproxy.common.I18nString;
import packetproxy.common.Utils;
import packetproxy.gui.GUIMain;
Expand Down Expand Up @@ -119,11 +118,7 @@ public void start() throws Exception {
}

private void startGUI() throws Exception {
String version = "1.0.0";
InputStream versionStream = getClass().getResourceAsStream("/version");
if (versionStream != null) {
version = IOUtils.toString(versionStream);
}
var version = AppVersion.get();
gui = GUIMain.getInstance(String.format("PacketProxy %s", version));
gui.setVisible(true);
}
Expand Down
50 changes: 50 additions & 0 deletions src/main/java/core/packetproxy/common/AppVersion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright 2026 DeNA Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package packetproxy.common;

import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.io.IOUtils;

public final class AppVersion {

private static final String DEFAULT_VERSION = "1.0.0";
private static String cached;

private AppVersion() {
}

public static String get() {
if (cached == null) {

cached = load();
}
return cached;
}

private static String load() {
try (InputStream in = AppVersion.class.getResourceAsStream("/version")) {
if (in == null) {

return DEFAULT_VERSION;
}
return IOUtils.toString(in).trim();
} catch (IOException e) {

return DEFAULT_VERSION;
}
}
}
Loading