March 6 2017

Java program convert decimal to binary

Java program convert decimal to binary

Decimal number system is a base 10 number system using digits for 0 to 9 whereas binary number system is base 2 and uses 0 and 1.

Algorithm to convert Decimal to Binary number

  1. Divide the decimal number by 2 and store the remainder
  2. Store the quotient back to the input number variable
  3. Repeat step 1 and 2 till quotient becomes zero.
  4. Binary number will be the remainders in above process in reverse order

Example             Continue reading

January 10 2017

Java BufferedWriter Example

Java BufferedWriter Example

BufferedWriter class writes text to a character-output stream, buffering characters and provides efficient writing of single characters, arrays, and strings. Compared to FileWriter, BufferedWriter writes relatively large amount of data to a file at once. The buffer size may be specified, or the default size may be used.

BufferedWriter provides a newLine() method to create platform-specific line separators automatically. Wrap the BufferedWriter around a FileWriter, to get access to high level methods.

Key methods: close(), flush(), newLine(), write()

Example Continue reading

January 2 2017

JAXB Unmarshaller Example

JAXB Unmarshaller Example

JAXB stands for Java Architecture for XML Binding. It provides mechanism to convert Java object to XML file (Marshalling) and XML file into a Java Object (Unmarshalling).

Unmarshalling

public interface Unmarshaller

The Unmarshaller class is responsible for converting XML data to Java Object.

Example Continue reading

Category: JAXB | LEAVE A COMMENT
January 2 2017

JAXB Marshaller Example

JAXB Marshaller Example

JAXB stands for Java Architecture for XML Binding. It provides mechanism to convert Java object to XML file (Marshalling) and XML file into a Java Object (Unmarshalling).

Marshalling

public interface Marshaller

The Marshaller class is responsible for converting Java object to XML data.

Example Continue reading

Category: JAXB | LEAVE A COMMENT