
Define an URL to a Local File
If we want to define a valid URL instance for a file we need to add the “file” protocol as in the following example: URL url = new URL(“file:///C:/photos/me.png”); Related

If we want to define a valid URL instance for a file we need to add the “file” protocol as in the following example: URL url = new URL(“file:///C:/photos/me.png”); Related

See how to use this form of Regex below to identify whether or not a string has only alphabets present. public class RegexHasOnlyAlphabets{ public static void main(String args[]) { RegexHasOnlyAlphabets

You can RESEED?Identity Columns of all tables by using sp_MSForEachTable?to loop through all the tables and executing the DBCC CHECKIDENT?command if the specific table has an identity column: EXEC sp_MSForEachTable

See how to add or subtract days, months or years with these operations. LocalDate tomorrow = LocalDate.now().plusDays(3);LocalDateTime anHourFromNow = LocalDateTime.now().plusHours(10);Long daysBetween = java.time.temporal.ChronoUnit.DAYS.between(LocalDate.now(), LocalDate.now().plusDays(2));Duration duration = Duration.between(Instant.now(), ZonedDateTime.parse(“2018-08-30T09:00:00+01:00[Europe/Stockholm]”)); Related Posts

You can use the IIF statement to check quickly for conditions. For example: DECLARE @Spy varchar(20) = ’07’ SELECT IIF(@Spy = ‘007’, ‘Bond, James Bond’, ‘Ernst Stavro Blofeld’) If the

Starting with Java 8, we can join several strings with a delimiter (e.g., comma) via the String.join() method: String result = String.join(“, “, “One”, “Two”, “Three”);// One, Two, ThreeSystem.out.println(result); Related

An interesting statement in MySQL is the INSERT ON DUPLICATE KEY UPDATE. This statement tries to INSERT?a record, and on finding a duplicate key, performs the action provided alongside. Example:

You can make use of the built-in sys.fn_builtin_permissions SQL function to get a list of available permissions, as shown below: SELECT * FROM sys.fn_builtin_permissions(DEFAULT);SELECT * FROM sys.fn_builtin_permissions(”); Related Posts Revolutionary AI

Beginning with JDK 10, we can rely on the Java Local Variable Type Inference (Var Type) in order to avoid explicit typing. Check out the following sample: var outputStream =

You can resize the tempdb temporary database in SQL by using the ALTER DATABASE command, as shown below: ALTER DATABASE tempdbMODIFY FILE (Name = tempdb_data, filesize = 100MB),MODIFY FILE (NAME

Assume there is a column named MARKS in the table STUDENT_DETAILS, and we need to calculate the average. The following query will be necessary: SELECT AVG(MARKS) AVERAGE FROM STUDENT_DETAILS; This

String and character literals provide an escape mechanism that allows express character codes that would otherwise not be allowed in the literal. An escape sequence consists of a backslash character

We use a lot of ng-templates in our HTML and have cases in which we would need to swap one with the other based on a condition. ngSwitch comes in

Java 9 has added the concept of module via Java Platform Module System. In order to obtain the names of packages from a module we can do it as follows:

You can get the language ID with the following Select statement: SET LANGUAGE ‘French’SELECT @@LANGID AS ‘Language ID’ Related Posts BT amplifies AI usage for cybersecurity defenseRun Your Backbone.js Apps

Use the “@ts-ignore” comment before the code and the compiler will ignore errors. // @ts-ignoreimport mathUnit from ‘mathjs/lib/type/unit’ Related Posts Capturing Textboxes Available in a Google Authentification Page Using SeleniumPotential

The Math package is feature-rich and some of the methods are illustrated below. public class MathPkg{public static void main(String args[]){MathPkg mathPkg = new MathPkg();mathPkg.proceed();}private void proceed(){int positiveNum = 5;int negativeNum

It is difficult to maintain correctness in mutable objects, as multiple threads could be trying to change the state of the same object. This can lead to some threads seeing

Using dm_db_index_physical_stats?returns size and fragmentation information for the data and indexes of the specified table or view in SQL Server. USE master; GO — If Student.Name does not exist in

Use the GetTempPath?method to retrieve the temp file path in a machine. Please note that it also varies from one operating system to other. string tempFilePath = System.IO.Path.GetTempPath(); Related Posts

Swapping two numbers without using a new variable is always a good approach. This helps your application to be memory and performance oriented. public class Swap2Numbers{ int firstNum = 10;

Before Java 8, this was obtained as a String[] via TimeZone class: String[] zoneIds = TimeZone.getAvailableIDs(); Java 8 comes with a new approach via java.time.ZoneId class: Set zoneIds = ZoneId.getAvailableZoneIds();

You can write results of a SELECT query into a text file in the following way: master..xp_cmdshell ‘osql -S SERVERNAME -U USERNAME -P PASSWORD -Q “SELECT * FROM TABLE” -d

See an easy way to enumerate all the values. public enum WorkTypes{Remote = 0,Office = 1,Exempted = 2}foreach (WorkTypes workType in Enum.GetValues(typeof(WorkTypes)))Console.WriteLine(workType); Related Posts Creating an HTML Table with SQLTop

Starting with JDK 8, you can avoid NullPointerException by returning an Optional. For example, instead of returning null, this method returns an empty Optional: public Optional fetchShoppingCart(long id) { ShoppingCart

One good way to quickly diagnose System slowdowns is to make use of the sp_who2 SQL function in the following way: EXEC sp_who2 This helps identify High CPU Usage, Blocking

You might be interested to know where the current code flow is. The getMethodName() method in the getStackTrace(), if used as illustrated below, is really helpful. As always, specific use

Use the System.Environment namespace’s GetFolderPath?method to retrieve the path of a special folder. It can also create the folder if it does not exist. System.Environment.GetFolderPath(Environment.SpecialFolder.Recent, Environment.SpecialFolderOption.None)) Related Posts Reading Text

Learn how to use the findAny method in java.util.Stream. This returns an Optional describing an element, or an empty Optional if Stream is empty. Also, remember that the same stream

In Java, characters as  cannot appear in a regular expression without being escaped. For this, rely on the Pattern.quote() method as in the following example: public static boolean contains(String t1, String