< prev index next >

src/jdk.jcmd/share/classes/sun/tools/jcmd/JCmd.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 24,34 **** */ package sun.tools.jcmd; import java.io.InputStream; - import java.io.InputStreamReader; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.List; import java.util.Collection; import java.util.Collections; --- 24,33 ----
*** 120,139 **** String lines[] = command.split("\\n"); for (String line : lines) { if (line.trim().equals("stop")) { break; } ! try (InputStream in = hvm.executeJCmd(line); ! InputStreamReader isr = new InputStreamReader(in, "UTF-8")) { // read to EOF and just print output ! char c[] = new char[256]; int n; boolean messagePrinted = false; do { ! n = isr.read(c); if (n > 0) { ! String s = new String(c, 0, n); System.out.print(s); messagePrinted = true; } } while (n > 0); if (!messagePrinted) { --- 119,137 ---- String lines[] = command.split("\\n"); for (String line : lines) { if (line.trim().equals("stop")) { break; } ! try (InputStream in = hvm.executeJCmd(line);) { // read to EOF and just print output ! byte b[] = new byte[256]; int n; boolean messagePrinted = false; do { ! n = in.read(b); if (n > 0) { ! String s = new String(b, 0, n, "UTF-8"); System.out.print(s); messagePrinted = true; } } while (n > 0); if (!messagePrinted) {
< prev index next >