-
Set window size
The size of a JavaFX application window can be set in two places.
It can be set in either the
Stageor theSceneobject using thewidthandheightvariables.

-
Delete a file or directory
Deleting a file or directory in Java is pretty simple. Create a
Fileobject and call the.delete()method on it.import java.io.File; File file = new File(filePath); file.delete();
The
.delete()method:
Returnstrueif the file/directory is deleted successfully
Returnsfalseif the file/directory is not deleted (ie. file not found, file is open)
Throws aSecurityExceptionif the application has insufficient permissions to delete the file/directory. -
Get the current URL
If you already know some information about the URL you can use that information to replace the respective part.
Start with an empty path
<?php
$path = "";
?>Check for the protocol (ie. http, cgi)
If you know the protocol is http you can replace this accordingly.<?php
// SERVER_PROTOCOL is in the form "protocol/rev#", this strips the revision
$path .= strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/");
?>Check if secure (HTTPS)
-
Read a text file using readLine()
One of the simplest ways to read in a text file in Java is to use the
readLine()method to read one line at a time. In this example the file is opened with aFileReader, buffered with aBufferedReader, and then read in using thereadLine()method.import java.io.*; public class ReadTextFile { public static void main(String[] args) { StringBuilder contents = new StringBuilder(); try { BufferedReader input = new BufferedReader(new FileReader("C:\\Temp\\myFile.txt"));
-
Convert a string to an integer using scanf and sscanf
int scanf ( const char * format, ... );
int sscanf ( const char * str, const char * format, ...);Getting input from keyboard (
stdin)
// NOTE: this uses scanf #include <stdio.h> int main() { int i; printf( "Enter an integer: " ); if( scanf( "%d", &i ) <=0 ) { printf ("ERROR"); } else { printf ("The integer value is: %d.",i); } return 0; }
