// Attach to pid and perform a thread dump private static void runThreadDump(String pid, String args[]) throws Exception { VirtualMachine vm = null; try { vm = VirtualMachine.attach(pid); } catch (Exception x) { String msg = x.getMessage(); if (msg != null) { System.err.println(pid + ": " + msg); } else { x.printStackTrace(); } if ((x instanceof AttachNotSupportedException) && (loadSAClass() != null)) { System.err.println( "The -F option can be used when the target " + "process is not responding"); } System.exit(1); } // Cast to HotSpotVirtualMachine as this is implementation specific // method. InputStream in = ((HotSpotVirtualMachine) vm).remoteDataDump((Object[]) args); // read to EOF and just print output byte b[] = new byte[256]; int n; do { n = in.read(b); if (n > 0) { String s = new String(b, 0, n, "UTF-8"); System.out.print(s); } } while (n > 0); in.close(); vm.detach(); }
public SF2Soundbank(URL url) throws IOException { InputStream is = url.openStream(); try { readSoundbank(is); } finally { is.close(); } }
public SF2Soundbank(File file) throws IOException { largeFormat = true; sampleFile = file; InputStream is = new FileInputStream(file); try { readSoundbank(is); } finally { is.close(); } }