test/java/lang/instrument/BootClassPath/Setup.java
Print this page
rev 3509 : 7021209: convert lang, math, util to use try-with-resources
Reviewed-by: XXX
*** 60,94 ****
/*
* Create manifest file with Boot-Class-Path encoding the
* sub-directory name.
*/
! FileOutputStream out = new FileOutputStream(manifestFile);
out.write("Manifest-Version: 1.0\n".getBytes("UTF-8"));
! byte[] premainBytes = ("Premain-Class: " + premainClass + "\n").getBytes("UTF-8");
out.write(premainBytes);
out.write( "Boot-Class-Path: ".getBytes("UTF-8") );
byte[] value = bootClassPath.getBytes("UTF-8");
for (int i=0; i<value.length; i++) {
int v = (int)value[i];
if (v < 0) v += 256;
! byte[] escaped = ("%" + Integer.toHexString(v)).getBytes("UTF-8");
out.write(escaped);
}
out.write( "\n\n".getBytes("UTF-8") );
! out.close();
/*
* Write the name of the boot dir to "boot.dir"
*/
f = new File(workDir + fileSeparator + "boot.dir");
! out = new FileOutputStream(f);
out.write(bootDir.getBytes(defaultEncoding));
! out.close();
}
/* ported from test/sun/tools/launcher/UnicodeTest.java */
private static final String fileSeparator = System.getProperty("file.separator");
--- 60,96 ----
/*
* Create manifest file with Boot-Class-Path encoding the
* sub-directory name.
*/
! try (FileOutputStream out = new FileOutputStream(manifestFile)) {
out.write("Manifest-Version: 1.0\n".getBytes("UTF-8"));
! byte[] premainBytes =
! ("Premain-Class: " + premainClass + "\n").getBytes("UTF-8");
out.write(premainBytes);
out.write( "Boot-Class-Path: ".getBytes("UTF-8") );
byte[] value = bootClassPath.getBytes("UTF-8");
for (int i=0; i<value.length; i++) {
int v = (int)value[i];
if (v < 0) v += 256;
! byte[] escaped =
! ("%" + Integer.toHexString(v)).getBytes("UTF-8");
out.write(escaped);
}
out.write( "\n\n".getBytes("UTF-8") );
! }
/*
* Write the name of the boot dir to "boot.dir"
*/
f = new File(workDir + fileSeparator + "boot.dir");
! try (FileOutputStream out = new FileOutputStream(f)) {
out.write(bootDir.getBytes(defaultEncoding));
! }
}
/* ported from test/sun/tools/launcher/UnicodeTest.java */
private static final String fileSeparator = System.getProperty("file.separator");