try { Runtime r = Runtime.getRuntime(); Process p = r.exec("code.exe"); InputStream in = p.getInputStream(); BufferedReader br = new BufferedReader(new InputStreamReader(in)); while (true) { String str = br.readLine(); if (str == null) break; System.out.println(str); } } catch ( Exception ee) { ee.printStackTrace(); }
Given the binary value 1000:
1000 = 1 * 2^{3} + 0 *2^{2} + 0 * 2^{1} + 0 * 2^{0} = 2^{3} = 8 (decimal)
Converting decimal to binary
Given the decimal value 10:
10 = 2^{3} + 2^{1} = 1 * 2^{3} + 0 * 2^{2} + 1 * 2^{1} + 0 * 2^{0} = 1010 (binary)An easier way to work this out is, for example (given a decimal number of 11): divide the decimal number by 2, recording the quotient and remainder in the next row, rounding the quotient DOWN each time, until you have a quotient of 0.
Quotient | Remainder | ||
---|---|---|---|
11 | |||
Repeat the procedure - divide by 2, record quotient and remainder in the next row | 5 | 1 | 11/2 = 5 remainder 1 |
Repeat again | 2 | 1 | 5/2 = 2 remainder 1 |
Repeat again | 1 | 0 | 2/2 = 1 remainder 0 |
Stop! Quotient = zero | 0 | 1 | 1/2= 0 remainder 1 |
Result: (read from bottom up) Decimal value 11 = binary 1011
mkdir /mnt/targetfolder /usr/bin/smbmount //NTMachineName/folder /mnt/targetfolder -o username=xxx,password=yyy