Node.js: printing to console without a trailing newline?

Is there a method for printing to the console without a trailing newline? The console object documentation doesn’t say anything regarding that: console.log() Prints to stdout with newline. This function can take multiple arguments in a printf()-like way. Example: console.log(‘count: %d’, count); If formating elements are not found in the first string then util.inspect is … Read more

How can I get the application’s path in a .NET console application?

How do I find the application’s path in a console application? In Windows Forms, I can use Application.StartupPath to find the current path, but this doesn’t seem to be available in a console application. 28 s 28 System.Reflection.Assembly.GetExecutingAssembly().Location1 Combine that with System.IO.Path.GetDirectoryName if all you want is the directory. 1As per Mr.Mindor’s comment: System.Reflection.Assembly.GetExecutingAssembly().Location returns … Read more

Colors in JavaScript console

Can Chrome’s built-in JavaScript console display colors? I want errors in red, warnings in orange and console.log‘s in green. Is that possible? 29 s 29 In Chrome & Firefox (+31) you can add CSS in console.log messages: console.log(‘%c Oh my heavens! ‘, ‘background: #222; color: #bada55’); The same can be applied for adding multiple CSS … Read more

How to clear the console?

Since there are several answers here showing non-working code for Windows, here is a clarification: Runtime.getRuntime().exec(“cls”); This command does not work, for two reasons: There is no executable named cls.exe or cls.com in a standard Windows installation that could be invoked via Runtime.exec, as the well-known command cls is builtin to Windows’ command line interpreter. When launching a new process via Runtime.exec, the standard output … Read more

Getting Keyboard Input

You can use Scanner class Import first : import java.util.Scanner; Then you use like this. Scanner keyboard = new Scanner(System.in); System.out.println(“enter an integer”); int myint = keyboard.nextInt(); Side note : If you are using nextInt() with nextLine() you probably could have some trouble cause nextInt() does not read the last newline character of input and so nextLine() then is not gonna to be executed with … Read more

Java console program

/* * put this in a file named CommandLineExample.java * */ class CommandLineExample { public static void main ( String [] arguments ) { System.out.println(“Hello, world”); } } type the following from the command line to compile it: $ javac CommandLineExample.java then you can run it from the command line like this: $ java CommandLineExample