提交 d52e22e3 编写于 作者: Z zhourui

fix

上级 80869fd0
......@@ -9,31 +9,31 @@ import java.nio.channels.FileLock;
public class Exit {
public static void main(String... args) throws Exception {
try (RandomAccessFile raf = new RandomAccessFile(getBasePath() + "/command.swap", "rw")) {
FileChannel fc = raf.getChannel();
MappedByteBuffer mbb = fc.map(MapMode.READ_WRITE, 0, 256);
FileLock flock = null;
flock = fc.lock();
mbb.put("exit".getBytes());
flock.release();
}
}
public static void main(String... args) throws Exception {
try (RandomAccessFile raf = new RandomAccessFile(getBasePath() + "/command.swap", "rw")) {
FileChannel fc = raf.getChannel();
MappedByteBuffer mbb = fc.map(MapMode.READ_WRITE, 0, 256);
FileLock flock = null;
flock = fc.lock();
mbb.put("exit".getBytes());
flock.release();
}
}
private static String getBasePath() throws Exception {
String path = Exit.class.getProtectionDomain().getCodeSource().getLocation().getPath();
File file = new File(path);
if (!file.isDirectory()) {
file = file.getParentFile();
}
while (null != file) {
File versionFile = new File(file, "version.o2");
if (versionFile.exists()) {
return file.getAbsolutePath();
}
file = file.getParentFile();
}
throw new Exception("can not define o2server base directory.");
}
private static String getBasePath() {
String path = Exit.class.getProtectionDomain().getCodeSource().getLocation().getPath();
File file = new File(path);
if (!file.isDirectory()) {
file = file.getParentFile();
}
while (null != file) {
File versionFile = new File(file, "version.o2");
if (versionFile.exists()) {
return file.getAbsolutePath();
}
file = file.getParentFile();
}
throw new IllegalStateException("can not define o2server base directory.");
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册