Tutorial by Examples: f

This option makes JRockit JVM exit on the first occurrence of an out of memory error. It can be used if you prefer restarting an instance of JRockit JVM rather than handling out of memory errors. Enter this command at startup to force JRockit JVM to exit on the first occurrence of an out of memory e...
We can use Channel to copy file content faster. To do so, we can use transferTo() method of FileChannel . import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.nio.channels.FileChannel; public class FileCopier { ...
Reading file using a BufferedInputStream generally faster than FileInputStream because it maintains an internal buffer to store bytes read from the underlying input stream. import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.IOException; public class FileReadin...
Drag a gesture recognizer from the object library onto your view. Control drag from the gesture in the Document Outline to your View Controller code in order to make an Outlet and an Action. Notes This example comes from this fuller sample project demonstrating gesture recognizers.
//Creates a Random instance with a seed of 12345. Random random = new Random(12345L); //Gets a ThreadLocalRandom instance ThreadLocalRandom tlr = ThreadLocalRandom.current(); //Set the instance's seed. tlr.setSeed(12345L); Using the same seed to generate random numbers will return the sa...
Jetty is a Java-based, open-source project providing a HTTP server/client and javax.servlet container. Jetty also provides support for HTTP/2, JMX, JNDI, OSGi JAAS and other integrations. Jetty can be deployed as a standard distribution package or as an embeddable web server, allowing users to custo...
Firstly the classes from the jar need to be loaded. We'll use three methods for this process: loadClasses(File) readJar(JarFile, JarEntry, Map) getNode(byte[]) Map<String, ClassNode> loadClasses(File jarFile) throws IOException { Map<String, ClassNode> classes = new HashMap&...
public static void main(String[] args) throws Exception { File jarFile = new File("Input.jar"); Map<String, ClassNode> nodes = JarUtils.loadClasses(jarFile); Map<String, byte[]> out = JarUtils.loadNonClassEntries(jarFile); Map<String, String> map...
Preconnect The preconnect relationship is similar to dns-prefetch in that it will resolve the DNS. However, it will also make the TCP handshake, and optional TLS negotiation. This is an experimental feature. <link rel="preconnect" href="URL"> DNS-Prefetch Informs bro...
To write data to a file using Channel we need to have the following steps: First, we need to get an object of FileOutputStream Acquire FileChannel calling the getChannel() method from the FileOutputStream Create a ByteBuffer and then fill it with data Then we have to call the flip() method of ...
We can use PrintStream class to write a file. It has several methods that let you print any data type values. println() method appends a new line. Once we are done printing, we have to flush the PrintStream. import java.io.FileNotFoundException; import java.io.PrintStream; import java.time.Local...
To print the value of a pointer to an object (as opposed to a function pointer) use the p conversion specifier. It is defined to print void-pointers only, so to print out the value of a non void-pointer it needs to be explicitly converted ("casted*") to void*. #include <stdlib.h> /*...
PHP provides support for the HTTP PUT method used by some clients to store files on a server. PUT requests are much simpler than a file upload using POST requests and they look something like this: PUT /path/filename.html HTTP/1.1 Into your PHP code you would then do something like this: <?p...
Python programs can read from unix pipelines. Here is a simple example how to read from stdin: import sys for line in sys.stdin: print(line) Be aware that sys.stdin is a stream. It means that the for-loop will only terminate when the stream has ended. You can now pipe the output of anot...
Sometimes we need to fetch and print the value of a TensorFlow variable to guarantee our program is correct. For example, if we have the following program: import tensorflow as tf import numpy as np a = tf.Variable(tf.random_normal([2,3])) # declare a tensorflow variable b = tf.random_normal([2...
When dealing with an unbalanced design and/or non-orthogonal contrasts, Type II or Type III Sum of Squares are necessary. The Anova() function from the car package implements these. Type II Sum of Squares assumes no interaction between main effects. If interactions are assumed, Type III Sum of Squar...
The current frame rate (in FPS, Frames Per Second) and total number of SKNodes in the scene (nodeCount, each sprite is an SKNode but other objects in the scene are also SKNodes) can be shown in the bottom right hand corner of the view. These can be useful when turned on (set to true) for debugging ...
An SKView does not need to fill the whole screen and can share space with other UI controls. You can even have more than one SKView displayed at once if you wish. To create a smaller SKView amongst other controls with Interface Builder, first create a normal ViewController, then drag and drop a new...
When a function returns an object (as opposed to using one that's passed in by the caller), be careful an exception doesn't cause the object to leak. function MakeStrings: TStrings; begin // Create a new object before entering the try-block. Result := TStringList.Create; try // Execu...
A try-finally block may be nested inside a try-except block. try AcquireResources; try UseResource; finally ReleaseResource; end; except on E: EResourceUsageError do begin HandleResourceErrors; end; end; If an exception occurs inside UseResource, then execution...

Page 164 of 457