Skip to main content

Posts

Showing posts from September, 2017

Learn Java to have Permanent Job or These 15 Languages

There are thousands of programming languages, but some are far more popular than others. When a company goes out to find new programming talent, they're looking for people familiar with the languages and systems they already use - even as newer languages like Apple Swift or Google Go start to make a splash. Here are the programming languages you should learn if you always want to have a job, as suggested by the popular TIOBE Index , the Redmonk Programming Language Rankings, and the annual Stack Overflow developer survey. Java C Python PHP Visual Basic Javascript R Go Ruby Groovy Objective-C Perl Pascal Delphi Object Pascal Swift MATLAB

Executing Shell Command From Java Program

Shell commands can be executed from within Java programs by using exec() method of Runtime class. See example below: try { Process process = Runtime.getRuntime().exec("your-command"); } catch (IOException e) { e.printStackTrace(); } Output of the executed command can also be read as Process proc = Runtime.getRuntime().exec("your-command"); BufferedReader stdInput = new BufferedReader(new      InputStreamReader(proc.getInputStream())); BufferedReader stdError = new BufferedReader(new      InputStreamReader(proc.getErrorStream())); System.out.println("Standard Output:\n"); String s = null; while ((s = stdInput.readLine()) != null) {     System.out.println(s); } System.out.println("Standard Error:\n"); while ((s = stdError.readLine()) != null) {     System.out.println(s); }