Files
Sudoku/app/src/main/java/gui/AssetManager.java
Persson-dev 990c830590
All checks were successful
Linux arm64 / Build (push) Successful in 41s
Fixes #5
2025-02-02 11:33:21 +01:00

33 lines
641 B
Java

package gui;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
public class AssetManager {
public static byte[] getResource(String name) {
// we first search it in files
File f = new File(name);
if (f.exists()){
FileInputStream fis;
try {
fis = new FileInputStream(f);
return fis.readAllBytes();
} catch (IOException e) {
e.printStackTrace();
}
}
// then in the jar
InputStream is = ClassLoader.getSystemResourceAsStream(name);
try {
return is.readAllBytes();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}