-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ba0fae
commit cf32b11
Showing
12 changed files
with
418 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
package com.hua.genshintools; | ||
|
||
import com.hua.genshintools.cache.Cache; | ||
import com.sun.jna.platform.win32.*; | ||
|
||
public class Main { | ||
public static void main(String[] args) { | ||
// User32.INSTANCE.CreateWindowEx() | ||
// Kernel32.INSTANCE.CreateProcessW() | ||
Cache.getCache().readCache(); | ||
System.out.println(System.getenv("user.dir")); | ||
HelloApplication.main(new String[0]); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
genshintools/src/main/java/com/hua/genshintools/cache/Cache.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.hua.genshintools.cache; | ||
|
||
//import com.google.gson.Gson; | ||
|
||
import javax.security.auth.callback.Callback; | ||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.FileOutputStream; | ||
import java.io.IOException; | ||
import java.nio.charset.Charset; | ||
|
||
|
||
public class Cache { | ||
private static final Cache cache=new Cache(); | ||
private File file = new File("./cache"); | ||
private File error = new File("./error"); | ||
private static Info info; | ||
public void readCache() { | ||
try { | ||
if (!file.exists()) { | ||
file.createNewFile(); | ||
info=new Info(); | ||
} else { | ||
FileInputStream in = new FileInputStream(file); | ||
// info=new Gson().fromJson(new String(in.readAllBytes(),Charset.defaultCharset()),Info.class); | ||
if(info==null)info=new Info(); | ||
} | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
||
} | ||
public void writeCache(){ | ||
try{ | ||
if(!file.exists()){ | ||
file.createNewFile(); | ||
}else if(info!=null){ | ||
FileOutputStream out=new FileOutputStream(file); | ||
// out.write(new Gson().toJson(info,Info.class).getBytes(Charset.defaultCharset())); | ||
} | ||
}catch(IOException e){ | ||
e.printStackTrace(); | ||
} | ||
} | ||
public void errPrint(String str){ | ||
try{ | ||
if(!error.exists()){ | ||
error.createNewFile(); | ||
}else if(info!=null){ | ||
FileOutputStream out=new FileOutputStream(file); | ||
out.write(str.getBytes(Charset.defaultCharset())); | ||
} | ||
}catch(IOException e){ | ||
e.printStackTrace(); | ||
} | ||
} | ||
public static Info getInfo(){ | ||
return info; | ||
} | ||
public static Cache getCache(){ | ||
return cache; | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
genshintools/src/main/java/com/hua/genshintools/cache/Info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.hua.genshintools.cache; | ||
|
||
public class Info{ | ||
public String lastOpen; | ||
public int GlobalBpm; | ||
|
||
public String getLastOpen() { | ||
return lastOpen; | ||
} | ||
|
||
public void setLastOpen(String lastOpen) { | ||
this.lastOpen = lastOpen; | ||
} | ||
|
||
public int getGlobalBpm() { | ||
return GlobalBpm; | ||
} | ||
|
||
public void setGlobalBpm(int globalBpm) { | ||
this.GlobalBpm = globalBpm; | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
genshintools/src/main/java/com/hua/genshintools/cache/Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.hua.genshintools.cache; | ||
|
||
|
||
import java.lang.reflect.Method; | ||
import java.nio.charset.Charset; | ||
import java.util.Calendar; | ||
import java.util.regex.Pattern; | ||
|
||
public class Test implements Runnable{ | ||
// public static void main(String[] args) { | ||
// System.out.println(Pattern.matches("[a-z\\(\\) ]", " ")); | ||
// byte b=(byte)0xff; | ||
// b&=0xff; | ||
// System.out.println(b==(byte)0xff); | ||
// char ch='\n'; | ||
// if(('a'<ch&&ch<'z')||('A'<ch&&ch<'Z')){ | ||
// System.out.println("true"); | ||
// }else System.out.println("false"); | ||
// System.out.println(b); | ||
// | ||
// System.out.println(Pattern.matches("[a-zA-Z0\\(\\)() ]", '0'+"")); | ||
// } | ||
//todo true||false&& | ||
|
||
@Override | ||
public void run() { | ||
//如果中断了,则跳出执行 | ||
while(true){ | ||
if(Thread.currentThread().isInterrupted()){ | ||
System.out.println("收到中断停止执行"); | ||
break; | ||
} | ||
reInterrupt(); | ||
} | ||
} | ||
|
||
private void reInterrupt(){ | ||
//模拟内部中断 | ||
try { | ||
Thread.sleep(1000); | ||
} catch (InterruptedException e) { | ||
System.out.println(Thread.currentThread().isInterrupted()); | ||
e.printStackTrace(); | ||
//检测中断状态 | ||
System.out.println(Thread.currentThread().isInterrupted()); | ||
//添加此行代码,因为虽然中断了,线程中断被捕获,然后中断消息也会被清除, | ||
//所以加入Thread.currentThread.interrupt(); | ||
//手动恢复中断状态 | ||
Thread.currentThread().interrupt(); | ||
//检测中断状态是否恢复 | ||
System.out.println(Thread.currentThread().isInterrupted()); | ||
} | ||
} | ||
|
||
public static void main(String[] args) { | ||
Thread thread=new Thread(new Test()); | ||
thread.start(); | ||
try { | ||
//先休眠,然后再让线程中断 | ||
Thread.sleep(5000); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
thread.interrupt(); | ||
} | ||
|
||
} |
Oops, something went wrong.