Tutorial by Examples

It is (almost always) a bad idea to call System.gc(). The javadoc for the gc() method specifies the following: "Calling the gc method suggests that the Java Virtual Machine expend effort toward recycling unused objects in order to make the memory they currently occupy available for quick re...
The Path class is used to programmaticaly represent a path in the file system (and can therefore point to files as well as directories, even to non-existent ones) A path can be obtained using the helper class Paths: Path p1 = Paths.get("/var/www"); Path p2 = Paths.get(URI.create("f...
Information about a path can be get using the methods of a Path object: toString() returns the string representation of the path Path p1 = Paths.get("/var/www"); // p1.toString() returns "/var/www" getFileName() returns the file name (or, more specifically, the last ...
Joining Two Paths Paths can be joined using the resolve() method. The path passed has to be a partial path, which is a path that doesn't include the root element. Path p5 = Paths.get("/home/"); Path p6 = Paths.get("arthur/files"); Path joined = p5.resolve(p6); Path otherJoi...
To interact with the filesystem you use the methods of the class Files. Checking existence To check the existence of the file or directory a path points to, you use the following methods: Files.exists(Path path) and Files.notExists(Path path) !Files.exists(path) does not neccesarily have t...
Files can be read byte- and line-wise using the Files class. Path p2 = Paths.get(URI.create("file:///home/testuser/File.txt")); byte[] content = Files.readAllBytes(p2); List<String> linesOfContent = Files.readAllLines(p2); Files.readAllLines() optionally takes a charset as para...
Files can be written bite- and line-wise using the Files class Path p2 = Paths.get("/home/testuser/File.txt"); List<String> lines = Arrays.asList( new String[]{"First line", "Second line", "Third line"}); Files.write(p2, lines); Files.writ...
The object-fit property will defines how an element will fit into a box with an established height and width. Usually applied to an image or video, Object-fit accepts the following five values: FILL object-fit:fill; Fill stretches the image to fit the content box without regard to the image...
When making a bind of something, for example a date you may want to show it in a specific format without messing around with it in the code. To do this we can use the StringFormat property. Here are some examples: Text="{Binding Path=ReleaseDate, StringFormat=dddd dd MMMM yyyy}" This...
Elm defines the following special type variables that have a particular meaning to the compiler: comparable: Comprised of Int, Float, Char, String and tuples thereof. This allows the use of the < and > operators. Example: You could define a function to find the smallest and largest eleme...
Open Computing Language (OpenCL) is a framework for writing programs that execute on CPUs, GPUs, and other parallel processors and accelerators. OpenCL specifies a programming language (based on C) that provides access to named on-chip memory, a model for executing tasks in parallel, and the abilit...
There is no single command to rename a MySQL database but a simple workaround can be used to achieve this by backing up and restoring: mysqladmin -uroot -p<password> create <new name> mysqldump -uroot -p<password> --routines <old name> | mysql -uroot -pmypassword <new na...
The following commands can be used to swap the names of two MySQL databases (<db1> and <db2>): mysqladmin -uroot -p<password> create swaptemp mysqldump -uroot -p<password> --routines <db1> | mysql -uroot -p<password> swaptemp mysqladmin -uroot -p<password&gt...
Renaming a table can be done in a single command: RENAME TABLE `<old name>` TO `<new name>`; The following syntax does exactly the same: ALTER TABLE `<old name>` RENAME TO `<new name>`; If renaming a temporary table, the ALTER TABLE version of the syntax must be used....
Renaming a column can be done in a single statement but as well as the new name, the "column definition" (i.e. its data type and other optional properties such as nullability, auto incrementing etc.) must also be specified. ALTER TABLE `<table name>` CHANGE `<old name>` `<n...
MERGE INTO targetTable t USING sourceTable s ON t.PKID = s.PKID WHEN MATCHED AND NOT EXISTS ( SELECT s.ColumnA, s.ColumnB, s.ColumnC INTERSECT SELECT t.ColumnA, t.ColumnB, s.ColumnC ) THEN UPDATE SET t.Colum...
$ printf '%(%F)T\n' 2016-08-17
$ printf -v now '%(%T)T' $ echo "$now" 12:42:47
Lets create a simple transformation to convert a CSV into an XML file. Our Transformation has to do the following: Read the CSV file Build the greetings message Save the greetings in the XML file Create a Transformation: Here's how to start the Transformation: To the left of the works...
Pentaho Data Integration comes in two varieties: Community Edition (CE) - Free version for developers Enterprise Edition (EE) - Paid version for enterprise use Installation steps: You can download Pentaho Data Integration Community Edition from Sourceforge.net. For the Enterprise Editio...

Page 771 of 1336