Category Archives: Beginner

Write or redirect standard output error stream to a file in java

We write error of an application(s) to standard error stream using System.err.print*. System.err.println(“1. Write error to a file”); We would like to redirect the application errors to a file.  e.g. System.err.println(“1. Write error to a file”) should be written to a file. We would like to set output stream, so that all errors will be… Read More »

Write or redirect console output to a file & again reset to standard output in java

In java application, we write to console output using System.out.print*. We would like to redirect console output to a file. (Stream output -> File) e.g. System.out.println(“1. Console output written to file”) should written to a file. Stream written to console output will be redirected to a file. We will demonstrate to reset the console output (Opposite… Read More »

Convert String to Integer in java (with example)

Given an String in java, we would like convert String to integer. We can convert String to integer using following methods. Convert String to integer using Integer.parseInt. Convert String to integer using Integer.valueOf. Convert String to integer using Integer constructor. Program – convert String to Integer in java (with example) package org.learn; public class ConvertStringToInt { public… Read More »

Convert decimal number to binary – (java api, iterative & recursive)

Given a decimal number (base 10), convert decimal number to binary number (base 2) using java. We will discuss various methods to convert decimal number to binary. Convert decimal to binary using Integer class Integer.toBinaryString Integer.toString Iterative program to convert decimal number to binary number. Recursive method to convert decimal number to binary number. Methods… Read More »

Convert hexadecimal to decimal – java api, iterative & recursive

Given a hexadecimal number, convert hexadecimal number to decimal number using java. We will discuss various methods to convert hexadecimal number to decimal. Convert hexadecimal to decimal using Integer class Integer.parseInt Iterative program to convert hexadecimal number to decimal. Recursive program to convert hexadecimal number to decimal. Methods – Convert hexadecimal number to integer in… Read More »

Page 1 of 41234