Zayko in the Net

Personal blog of Vitaly Zayko


How to disable/enable Hyper-V on Windows with one simple string.

Don't get me wrong: Hyper-V is very great technology. But, unfortunately, in case when Hyper-V is active, you won't be able to run other virtualization. Why you might need that? For example, if you decide to work with Docker locally, or you need to run Android emulators. Here is how to disable Hyper-V in one simple command:

dism.exe /Online /Disable-Feature:Microsoft-Hyper-V

And, of course, the apposite action:

dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All

Please, be prepared to reboot your PC after these actions.

How to convert an InputStream to String? (Java, Android)

If you call a Web service from your Android App (I believe this should work in other Java Apps as well but personally tested in Android), you probably will want to convert InputStream into a string which is not that simple. And here is simpliest way how to do that:

 HttpURLConnection conn = (HttpURLConnection)url.openConnection();
 if(conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
 	InputStream inStream = new BufferedInputStream(conn.getInputStream());
     // Here are we go:
  String res = new Scanner(inStream).useDelimiter("\\\\A").next();