File Input Output Operations in Java Using Byte Streams

Java programs can perform I/O operations using byte streams i.e. one byte at a time. All byte stream classes are descended from InputStream and OutputStream. There are several byte stream classes, here we will focus on the file I/O byte streams, FileInputStream and FileOutputStream. The …

Calculate the Execution Time of a Java Progam

When we write an algorithm in any language, we must check the execution time of that algorithm. A bad code might eat a ginormous amount of resources that will result in slow execution of the program. There might be several ways to find the running …

Platform Independent New Line Character in Java

Unix, Windows/DOS, and Mac have somewhat different newline characters to indicate the end-of-line. Unix uses ‘\n’ (linefeed) as the line separator. Some Windows/DOS application programs allow ‘\n’ as the newline character, but many expect a pair of characters ‘\r\n’ (carriage return followed by line feed). For …

Haskell code for Set Difference

It’s required not to use the built-in set functions to calculate the difference between the given sets. In this scenario, we need to compare the elements of the sets to find the difference. To figure out if an element of a set is present in …