Tutorial by Examples: 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 ...
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...
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...
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...
In C and C++, the asterisk in the declaration of a pointer variable is part of the expression being declared. In C#, the asterisk in the declaration is part of the type. In C, C++ and C#, the following snippet declares an int pointer: int* a; In C and C++, the following snippet declares an int ...
Implementation of IDatabaseInitializer that is used in EntityFramework by default. As the name implies, it creates the database if none exists. However when you change the model, it throws an exception. Usage: public class MyContext : DbContext { public MyContext() { Database.SetIni...
This implementation of IDatabaseInitializer drops and recreates the database if the model changes automatically. Usage: public class MyContext : DbContext { public MyContext() { Database.SetInitializer(new DropCreateDatabaseIfModelChanges<MyContext>()); } }
A complex type allows you to map selected fields of a database table into a single type that is a child of the main type. [ComplexType] public class Address { public string Street { get; set; } public string Street_2 { get; set; } public string City { get; set; } public string...
Transformations alter a given point's starting position by moving, rotating & scaling that point. Translation: Moves a point by a distanceX and distanceY. Rotation: Rotates a point by a radian angle around it's rotation point. The default rotation point in Html Canvas is the top-left origin ...
Canvas allows you to context.translate, context.rotate and context.scale in order to draw your shape in the position & size you require. Canvas itself uses a transformation matrix to efficiently track transformations. You can change Canvas's matrix with context.transform You can change Canv...
Spark uses lazy evaluation; that means it will not do any work, unless it really has to. That approach allows us to avoid unnecessary memory usage, thus making us able to work with big data. A transformation is lazy evaluated and the actual work happens, when an action occurs. Example: In [1]: li...
Make sure the following dependency is added to your app's build.gradle file under dependencies: compile 'com.android.support:support-core-ui:24.2.0' Then add the SwipeRefreshLayout in your layout: <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/swipe_refresh_layo...
While the if ()... else statement allows to define only one (default) behaviour which occurs when the condition within the if () is not met, chaining two or more if () ... else statements allow to define a couple more behaviours before going to the last else branch acting as a "default", i...
In .NET, the GC allocates objects when there are no references left to them. Therefore, while an object can still be reached from code (there is a strong reference to it), the GC will not allocate this object. This can become a problem if there are a lot of large objects. A weak reference is a ref...

Page 258 of 457