How to write to file in Java – FileOutputStream
In Java, FileOutputStream is a bytes stream class that’s used to handle raw binary data. To write the data to file, you have to convert the data into bytes and…
Favourite tutorials for developers
Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. It is a general-purpose programming language intended to let programmers write once, run anywhere (WORA), meaning that compiled Java code can run on all platforms that support Java without the need to recompile.
In Java, FileOutputStream is a bytes stream class that’s used to handle raw binary data. To write the data to file, you have to convert the data into bytes and…
Here is another example to show how to read a file in Java with BufferedInputStream and DataInputStream classes. The readLine() from the type DataInputStream is deprecated. Sun officially announced this…
In Java, file permissions are very OS specific: *nix , NTFS (windows) and FAT/FAT32, all have different kind of file permissions. Java comes with some generic file permission to deal…
In non static method, we use getClass() of the object or instance. In static method, the getClass() method will be failed, and prompts Cannot make a static reference to the…
In Java, the System.getenv() returns an unmodifiable string Map view of the current system environment. If a requested environment variable is not defined, the System.getenv will return a null, and…
Normally, Java properties file is used to store project configuration data or settings. In this tutorial, we will show you how to read and write to/from a .properties file. The…
Few Java examples to sort a Map by its keys or values: (1) Uses java.util.TreeMap, it will sort the Map by keys automatically, (2) Yet another java.util.TreeMap example, provide a…
Java 8 Stream examples to sort a Map, by keys or by values. Steps to sort a Map in Java 8: (1) Convert a Map into a Stream, (2) Sort…
In Java, you can use System.getProperties() to get all the system properties. Also by sorting, you can display all the system properties in Alphabetical order.
This article shows a handy Java class that uses System.getProperty("os.name") to detect which type of operating system (OS) you are using now. This code can detect Windows, Mac, Unix, and…