Tutorial by Examples: n

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...
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...
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...
$ 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...
Sometimes when working with linear regression we need to check for non-linearity in the data. One way to do this is to fit a polynomial model and check whether it fits the data better than a linear model. There are other reasons, such as theoretical, that indicate to fit a quadratic or higher order ...
This example demonstrates how pointers can be used for C-like access to C# arrays. unsafe { var buffer = new int[1024]; fixed (int* p = &buffer[0]) { for (var i = 0; i < buffer.Length; i++) { *(p + i) = i; } } } The unsafe keyw...
Addition and subtraction in pointers works differently from integers. When a pointer is incremented or decremented, the address it points to is increased or decreased by the size of the referent type. For example, the type int (alias for System.Int32) has a size of 4. If an int can be stored in add...
C# inherits from C and C++ the usage of the symbol -> as a means of accessing the members of an instance through a typed pointer. Consider the following struct: struct Vector2 { public int X; public int Y; } This is an example of the usage of -> to access its members: Vector2...

Page 627 of 1088