5 changed files with 90 additions and 7 deletions
-
2src/main/java/a8k/app/constant/AppVersion.java
-
6src/main/java/a8k/app/service/data/FileMgrService.java
-
6src/main/java/a8k/app/service/os/OSDeviceInfoMgrService.java
-
55src/main/java/a8k/app/utils/ZFileUtils.java
-
28src/main/java/a8k/extui/page/extapp/VirtualStateGenerateModeSettingPage.java
@ -1,5 +1,5 @@ |
|||
package a8k.app.constant; |
|||
|
|||
public class AppVersion { |
|||
public static final String APP_VERSION = "B80.CN.01.00.07"; |
|||
public static final String APP_VERSION = "B80.CN.01.00.08"; |
|||
} |
@ -0,0 +1,55 @@ |
|||
package a8k.app.utils; |
|||
|
|||
import java.io.File; |
|||
import java.io.FileReader; |
|||
import java.io.FileWriter; |
|||
import java.io.IOException; |
|||
import java.nio.file.Files; |
|||
import java.nio.file.Path; |
|||
|
|||
public class ZFileUtils { |
|||
static public String getDirPath(String fullPath) { |
|||
File file = new File(fullPath); |
|||
if (file.isDirectory()) { |
|||
return fullPath; |
|||
} else { |
|||
return file.getParent(); |
|||
} |
|||
} |
|||
|
|||
static public void forceCreateDir(String path) throws IOException { |
|||
String dirPath = getDirPath(path); |
|||
File dir = new File(dirPath); |
|||
if (!dir.exists()) { |
|||
boolean suc = dir.mkdirs(); |
|||
if (!suc) { |
|||
throw new IOException("Failed to create directory: " + path); |
|||
} |
|||
} |
|||
} |
|||
|
|||
static public void writeUtf8String(String val, String path) throws IOException { |
|||
forceCreateDir(path); |
|||
File file = new File(path); |
|||
try (FileWriter writer = new FileWriter(file.getAbsolutePath())) { |
|||
writer.write(val); |
|||
} |
|||
} |
|||
|
|||
|
|||
static public String readUtf8String(String path) throws IOException { |
|||
File file = new File(path); |
|||
return Files.readString(Path.of(file.getAbsolutePath())); |
|||
} |
|||
|
|||
public static void main(String[] args) { |
|||
try { |
|||
String filepath = "runenv/123/testFile.txt"; |
|||
writeUtf8String("Hello, World!", filepath); |
|||
String content = readUtf8String(filepath); |
|||
System.out.println("File content: " + content); |
|||
} catch (IOException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue