Java源码示例:sun.tools.native2ascii.Main
示例1
public static void realMain(String[] args) throws Throwable {
if (!System.getProperty("os.name").startsWith("Windows")) {
String src = "native2ascii_permtest_src";
String dst = "native2ascii_permtest_dst";
cleanup(src, dst);
try {
try (FileOutputStream fos = new FileOutputStream(src)) {
fos.write('a'); fos.write('b'); fos.write('c');
}
String[] n2aArgs = new String[] {"-encoding", "utf8", src, dst};
if (!new Main().convert(n2aArgs)) {
fail("n2a failed.");
}
equal(Files.getPosixFilePermissions(Paths.get(src)),
Files.getPosixFilePermissions(Paths.get(dst)));
String[] a2nArgs = new String[] {"-reverse", "-encoding", "utf8", dst, src};
if (!new Main().convert(a2nArgs)) {
fail("a2n failed.");
}
equal(Files.getPosixFilePermissions(Paths.get(src)),
Files.getPosixFilePermissions(Paths.get(dst)));
} finally {
cleanup(src, dst);
}
}
}
示例2
public static void realMain(String[] args) throws Throwable {
if (!System.getProperty("os.name").startsWith("Windows")) {
String src = "native2ascii_permtest_src";
String dst = "native2ascii_permtest_dst";
cleanup(src, dst);
try {
try (FileOutputStream fos = new FileOutputStream(src)) {
fos.write('a'); fos.write('b'); fos.write('c');
}
String[] n2aArgs = new String[] {"-encoding", "utf8", src, dst};
if (!new Main().convert(n2aArgs)) {
fail("n2a failed.");
}
equal(Files.getPosixFilePermissions(Paths.get(src)),
Files.getPosixFilePermissions(Paths.get(dst)));
String[] a2nArgs = new String[] {"-reverse", "-encoding", "utf8", dst, src};
if (!new Main().convert(a2nArgs)) {
fail("a2n failed.");
}
equal(Files.getPosixFilePermissions(Paths.get(src)),
Files.getPosixFilePermissions(Paths.get(dst)));
} finally {
cleanup(src, dst);
}
}
}
示例3
public static void realMain(String[] args) throws Throwable {
if (!System.getProperty("os.name").startsWith("Windows")) {
String src = "native2ascii_permtest_src";
String dst = "native2ascii_permtest_dst";
cleanup(src, dst);
try {
try (FileOutputStream fos = new FileOutputStream(src)) {
fos.write('a'); fos.write('b'); fos.write('c');
}
String[] n2aArgs = new String[] {"-encoding", "utf8", src, dst};
if (!new Main().convert(n2aArgs)) {
fail("n2a failed.");
}
equal(Files.getPosixFilePermissions(Paths.get(src)),
Files.getPosixFilePermissions(Paths.get(dst)));
String[] a2nArgs = new String[] {"-reverse", "-encoding", "utf8", dst, src};
if (!new Main().convert(a2nArgs)) {
fail("a2n failed.");
}
equal(Files.getPosixFilePermissions(Paths.get(src)),
Files.getPosixFilePermissions(Paths.get(dst)));
} finally {
cleanup(src, dst);
}
}
}
示例4
public static void realMain(String[] args) throws Throwable {
if (!System.getProperty("os.name").startsWith("Windows")) {
String src = "native2ascii_permtest_src";
String dst = "native2ascii_permtest_dst";
cleanup(src, dst);
try {
try (FileOutputStream fos = new FileOutputStream(src)) {
fos.write('a'); fos.write('b'); fos.write('c');
}
String[] n2aArgs = new String[] {"-encoding", "utf8", src, dst};
if (!new Main().convert(n2aArgs)) {
fail("n2a failed.");
}
equal(Files.getPosixFilePermissions(Paths.get(src)),
Files.getPosixFilePermissions(Paths.get(dst)));
String[] a2nArgs = new String[] {"-reverse", "-encoding", "utf8", dst, src};
if (!new Main().convert(a2nArgs)) {
fail("a2n failed.");
}
equal(Files.getPosixFilePermissions(Paths.get(src)),
Files.getPosixFilePermissions(Paths.get(dst)));
} finally {
cleanup(src, dst);
}
}
}
示例5
public static void realMain(String[] args) throws Throwable {
if (!System.getProperty("os.name").startsWith("Windows")) {
String src = "native2ascii_permtest_src";
String dst = "native2ascii_permtest_dst";
cleanup(src, dst);
try {
try (FileOutputStream fos = new FileOutputStream(src)) {
fos.write('a'); fos.write('b'); fos.write('c');
}
String[] n2aArgs = new String[] {"-encoding", "utf8", src, dst};
if (!new Main().convert(n2aArgs)) {
fail("n2a failed.");
}
equal(Files.getPosixFilePermissions(Paths.get(src)),
Files.getPosixFilePermissions(Paths.get(dst)));
String[] a2nArgs = new String[] {"-reverse", "-encoding", "utf8", dst, src};
if (!new Main().convert(a2nArgs)) {
fail("a2n failed.");
}
equal(Files.getPosixFilePermissions(Paths.get(src)),
Files.getPosixFilePermissions(Paths.get(dst)));
} finally {
cleanup(src, dst);
}
}
}
示例6
public static void realMain(String[] args) throws Throwable {
if (!System.getProperty("os.name").startsWith("Windows")) {
String src = "native2ascii_permtest_src";
String dst = "native2ascii_permtest_dst";
cleanup(src, dst);
try {
try (FileOutputStream fos = new FileOutputStream(src)) {
fos.write('a'); fos.write('b'); fos.write('c');
}
String[] n2aArgs = new String[] {"-encoding", "utf8", src, dst};
if (!new Main().convert(n2aArgs)) {
fail("n2a failed.");
}
equal(Files.getPosixFilePermissions(Paths.get(src)),
Files.getPosixFilePermissions(Paths.get(dst)));
String[] a2nArgs = new String[] {"-reverse", "-encoding", "utf8", dst, src};
if (!new Main().convert(a2nArgs)) {
fail("a2n failed.");
}
equal(Files.getPosixFilePermissions(Paths.get(src)),
Files.getPosixFilePermissions(Paths.get(dst)));
} finally {
cleanup(src, dst);
}
}
}
示例7
public static void realMain(String[] args) throws Throwable {
if (!System.getProperty("os.name").startsWith("Windows")) {
String src = "native2ascii_permtest_src";
String dst = "native2ascii_permtest_dst";
cleanup(src, dst);
try {
try (FileOutputStream fos = new FileOutputStream(src)) {
fos.write('a'); fos.write('b'); fos.write('c');
}
String[] n2aArgs = new String[] {"-encoding", "utf8", src, dst};
if (!new Main().convert(n2aArgs)) {
fail("n2a failed.");
}
equal(Files.getPosixFilePermissions(Paths.get(src)),
Files.getPosixFilePermissions(Paths.get(dst)));
String[] a2nArgs = new String[] {"-reverse", "-encoding", "utf8", dst, src};
if (!new Main().convert(a2nArgs)) {
fail("a2n failed.");
}
equal(Files.getPosixFilePermissions(Paths.get(src)),
Files.getPosixFilePermissions(Paths.get(dst)));
} finally {
cleanup(src, dst);
}
}
}
示例8
public static void realMain(String[] args) throws Throwable {
if (!System.getProperty("os.name").startsWith("Windows")) {
String src = "native2ascii_permtest_src";
String dst = "native2ascii_permtest_dst";
cleanup(src, dst);
try {
try (FileOutputStream fos = new FileOutputStream(src)) {
fos.write('a'); fos.write('b'); fos.write('c');
}
String[] n2aArgs = new String[] {"-encoding", "utf8", src, dst};
if (!new Main().convert(n2aArgs)) {
fail("n2a failed.");
}
equal(Files.getPosixFilePermissions(Paths.get(src)),
Files.getPosixFilePermissions(Paths.get(dst)));
String[] a2nArgs = new String[] {"-reverse", "-encoding", "utf8", dst, src};
if (!new Main().convert(a2nArgs)) {
fail("a2n failed.");
}
equal(Files.getPosixFilePermissions(Paths.get(src)),
Files.getPosixFilePermissions(Paths.get(dst)));
} finally {
cleanup(src, dst);
}
}
}
示例9
public static void realMain(String[] args) throws Throwable {
if (!System.getProperty("os.name").startsWith("Windows")) {
String src = "native2ascii_permtest_src";
String dst = "native2ascii_permtest_dst";
cleanup(src, dst);
try {
try (FileOutputStream fos = new FileOutputStream(src)) {
fos.write('a'); fos.write('b'); fos.write('c');
}
String[] n2aArgs = new String[] {"-encoding", "utf8", src, dst};
if (!new Main().convert(n2aArgs)) {
fail("n2a failed.");
}
equal(Files.getPosixFilePermissions(Paths.get(src)),
Files.getPosixFilePermissions(Paths.get(dst)));
String[] a2nArgs = new String[] {"-reverse", "-encoding", "utf8", dst, src};
if (!new Main().convert(a2nArgs)) {
fail("a2n failed.");
}
equal(Files.getPosixFilePermissions(Paths.get(src)),
Files.getPosixFilePermissions(Paths.get(dst)));
} finally {
cleanup(src, dst);
}
}
}
示例10
public static void realMain(String[] args) throws Throwable {
if (!System.getProperty("os.name").startsWith("Windows")) {
String src = "native2ascii_permtest_src";
String dst = "native2ascii_permtest_dst";
cleanup(src, dst);
try {
try (FileOutputStream fos = new FileOutputStream(src)) {
fos.write('a'); fos.write('b'); fos.write('c');
}
String[] n2aArgs = new String[] {"-encoding", "utf8", src, dst};
if (!new Main().convert(n2aArgs)) {
fail("n2a failed.");
}
equal(Files.getPosixFilePermissions(Paths.get(src)),
Files.getPosixFilePermissions(Paths.get(dst)));
String[] a2nArgs = new String[] {"-reverse", "-encoding", "utf8", dst, src};
if (!new Main().convert(a2nArgs)) {
fail("a2n failed.");
}
equal(Files.getPosixFilePermissions(Paths.get(src)),
Files.getPosixFilePermissions(Paths.get(dst)));
} finally {
cleanup(src, dst);
}
}
}
示例11
public static void realMain(String[] args) throws Throwable {
if (!System.getProperty("os.name").startsWith("Windows")) {
String src = "native2ascii_permtest_src";
String dst = "native2ascii_permtest_dst";
cleanup(src, dst);
try {
try (FileOutputStream fos = new FileOutputStream(src)) {
fos.write('a'); fos.write('b'); fos.write('c');
}
String[] n2aArgs = new String[] {"-encoding", "utf8", src, dst};
if (!new Main().convert(n2aArgs)) {
fail("n2a failed.");
}
equal(Files.getPosixFilePermissions(Paths.get(src)),
Files.getPosixFilePermissions(Paths.get(dst)));
String[] a2nArgs = new String[] {"-reverse", "-encoding", "utf8", dst, src};
if (!new Main().convert(a2nArgs)) {
fail("a2n failed.");
}
equal(Files.getPosixFilePermissions(Paths.get(src)),
Files.getPosixFilePermissions(Paths.get(dst)));
} finally {
cleanup(src, dst);
}
}
}
示例12
public static void realMain(String[] args) throws Throwable {
if (!System.getProperty("os.name").startsWith("Windows")) {
String src = "native2ascii_permtest_src";
String dst = "native2ascii_permtest_dst";
cleanup(src, dst);
try {
try (FileOutputStream fos = new FileOutputStream(src)) {
fos.write('a'); fos.write('b'); fos.write('c');
}
String[] n2aArgs = new String[] {"-encoding", "utf8", src, dst};
if (!new Main().convert(n2aArgs)) {
fail("n2a failed.");
}
equal(Files.getPosixFilePermissions(Paths.get(src)),
Files.getPosixFilePermissions(Paths.get(dst)));
String[] a2nArgs = new String[] {"-reverse", "-encoding", "utf8", dst, src};
if (!new Main().convert(a2nArgs)) {
fail("a2n failed.");
}
equal(Files.getPosixFilePermissions(Paths.get(src)),
Files.getPosixFilePermissions(Paths.get(dst)));
} finally {
cleanup(src, dst);
}
}
}