mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2026-05-19 15:34:39 -04:00
Changes
- [JRE auto install] Use short-hand methods - [IOUtils.copy()] check and add close() after them
This commit is contained in:
@@ -364,31 +364,18 @@ public class PojavLoginActivity extends BaseActivity
|
||||
fos.close();
|
||||
iis.close();
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
FileInputStream fis = new FileInputStream(new File(Tools.MAIN_PATH + "/lwjgl3/version"));
|
||||
byte[] release1 = new byte[is.available()];
|
||||
byte[] release2 = new byte[fis.available()];
|
||||
is.read(release1);
|
||||
fis.read(release2);
|
||||
if(!Arrays.equals(release1,release2)) {
|
||||
if (!Arrays.equals(release1,release2)) {
|
||||
String[] lwjglFileList = am.list("components/lwjgl3");
|
||||
FileOutputStream fos;
|
||||
InputStream iis;
|
||||
for(String s : lwjglFileList) {
|
||||
iis = am.open("components/lwjgl3/"+s);
|
||||
fos = new FileOutputStream(new File(Tools.MAIN_PATH+"/lwjgl3/"+s));
|
||||
/*
|
||||
int i; byte[] buf = new byte[1024];
|
||||
while((i = iis.read(buf)) != -1) {
|
||||
fos.write(buf,0,i);
|
||||
}
|
||||
*/
|
||||
IOUtils.copy(iis,fos);
|
||||
|
||||
fos.close();
|
||||
iis.close();
|
||||
for (String s : lwjglFileList) {
|
||||
Tools.copyAssetFile(this, "components/lwjgl3/" + s, Tools.MAIN_PATH + "/lwjgl3", true);
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
Log.i("LWJGL3Prep","Pack is up-to-date with the launcher, continuing...");
|
||||
}
|
||||
}
|
||||
@@ -399,10 +386,7 @@ public class PojavLoginActivity extends BaseActivity
|
||||
uncompressTarXZ(jreTarFile, new File(Tools.homeJreDir));
|
||||
}
|
||||
setPref(PREF_IS_INSTALLED_JAVARUNTIME, true);
|
||||
byte[] buf = new byte[1024];
|
||||
int i = am.open("components/jre/version").read(buf);;
|
||||
String s = new String(buf,0,i);
|
||||
setPref(PREF_JAVARUNTIME_VER,s);
|
||||
setPref(PREF_JAVARUNTIME_VER, Tools.read(am.open("components/jre/version")));
|
||||
}
|
||||
|
||||
JREUtils.relocateLibPath(this);
|
||||
@@ -464,10 +448,11 @@ public class PojavLoginActivity extends BaseActivity
|
||||
private void copyDummyNativeLib(String name) throws Throwable {
|
||||
File fileLib = new File(Tools.homeJreDir, Tools.homeJreLib + "/" + name);
|
||||
fileLib.delete();
|
||||
IOUtils.copy(
|
||||
new FileInputStream(new File(getApplicationInfo().nativeLibraryDir, name)),
|
||||
new FileOutputStream(fileLib)
|
||||
);
|
||||
FileInputStream is = new FileInputStream(new File(getApplicationInfo().nativeLibraryDir, name));
|
||||
FileOutputStream os = new FileOutputStream(fileLib);
|
||||
IOUtils.copy(is, os);
|
||||
is.close();
|
||||
os.close();
|
||||
}
|
||||
|
||||
private File selectJreTarFile() throws InterruptedException {
|
||||
@@ -562,7 +547,9 @@ public class PojavLoginActivity extends BaseActivity
|
||||
destPath.createNewFile();
|
||||
// destPath.setExecutable(true);
|
||||
|
||||
IOUtils.copy(tarIn, new FileOutputStream(destPath));
|
||||
FileOutputStream os = new FileOutputStream(destPath);
|
||||
IOUtils.copy(tarIn, os);
|
||||
os.close();
|
||||
|
||||
/*
|
||||
byte[] btoRead = new byte[2048];
|
||||
|
||||
@@ -674,8 +674,8 @@ public final class Tools
|
||||
outPath.getParentFile().mkdirs();
|
||||
outPath.createNewFile();
|
||||
|
||||
FileOutputStream fos = new FileOutputStream(path);
|
||||
fos.write(content);
|
||||
BufferedOutputStream fos = new BufferedOutputStream(new FileOutputStream(path));
|
||||
fos.write(content, 0, content.length);
|
||||
fos.close();
|
||||
}
|
||||
|
||||
@@ -704,6 +704,7 @@ public final class Tools
|
||||
File file = new File(nameOutput);
|
||||
DownloadUtils.downloadFile(urlInput, file);
|
||||
}
|
||||
|
||||
public static class ZipTool
|
||||
{
|
||||
private ZipTool(){}
|
||||
|
||||
@@ -37,8 +37,10 @@ public class LegacyForgeInstaller extends BaseInstaller {
|
||||
libraryFile.getParentFile().mkdirs();
|
||||
target = libraryFile.getAbsolutePath().replace("-universal", "");
|
||||
ctx.appendlnToLog("Writing " + target);
|
||||
InputStream in = mJarFile.getInputStream(mJarFile.getEntry(profile.install.filePath));
|
||||
FileOutputStream out = new FileOutputStream(target);
|
||||
IOUtils.copy(mJarFile.getInputStream(mJarFile.getEntry(profile.install.filePath)), out);
|
||||
IOUtils.copy(in, out);
|
||||
in.close();
|
||||
out.close();
|
||||
|
||||
mJarFile.close();
|
||||
|
||||
@@ -125,7 +125,11 @@ public class MinecraftDownloaderTask extends AsyncTask<String, String, Throwable
|
||||
} catch (Throwable th) {
|
||||
if (verInfo.inheritsFrom != null) {
|
||||
minecraftMainFile.delete();
|
||||
IOUtils.copy(new FileInputStream(new File(Tools.versnDir, verInfo.inheritsFrom + "/" + verInfo.inheritsFrom + ".jar")), new FileOutputStream(minecraftMainFile));
|
||||
FileInputStream is = new FileInputStream(new File(Tools.versnDir, verInfo.inheritsFrom + "/" + verInfo.inheritsFrom + ".jar"));
|
||||
FileOutputStream os = new FileOutputStream(minecraftMainFile);
|
||||
IOUtils.copy(is, os);
|
||||
is.close();
|
||||
os.close();
|
||||
} else {
|
||||
throw th;
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ public class DownloadUtils {
|
||||
public static String downloadString(String url) throws IOException {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
download(url, bos);
|
||||
bos.close();
|
||||
return new String(bos.toByteArray(), utf8);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user