How to clear the console using Java?

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. … Read more

Redirect Trace output to Console

You can add the following to your exe’s .config file. <?xml version=”1.0″?> <configuration> <system.diagnostics> <trace autoflush=”true”> <listeners> <add name=”logListener” type=”System.Diagnostics.TextWriterTraceListener” initializeData=”cat.log” /> <add name=”consoleListener” type=”System.Diagnostics.ConsoleTraceListener”/> </listeners> </trace> </system.diagnostics> </configuration> I included the TextWriter as well, in case you’re interested in logging to a file.

Read input.txt file and also output.bmp file from terminal (C-programming)

The full prototype for a standard main() is int main(int argc, char* argv[]); You get an int with the number of arguments, argc and a list of “strings” (as far as they exist in C), argv. You can for example use #include “stdio.h” int main(int argc, char* argv[]) { printf(“Number: %d\n”, argc); printf(“0: %s\n”, argv[0]); … Read more

How to split string preserving whole words?

Try this: static void Main(string[] args) { int partLength = 35; string sentence = “Silver badges are awarded for longer term goals. Silver badges are uncommon.”; string[] words = sentence.Split(‘ ‘); var parts = new Dictionary<int, string>(); string part = string.Empty; int partCounter = 0; foreach (var word in words) { if (part.Length + word.Length … Read more

Powershell output column width

I encountered a similar problem a while back. Here’s what I did to fix it: # Update output buffer size to prevent clipping in Visual Studio output window. if( $Host -and $Host.UI -and $Host.UI.RawUI ) { $rawUI = $Host.UI.RawUI $oldSize = $rawUI.BufferSize $typeName = $oldSize.GetType( ).FullName $newSize = New-Object $typeName (500, $oldSize.Height) $rawUI.BufferSize = $newSize … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)