OCP

Java NIO.2

Posted on

Non blocking IO in Java, released with Java 7. Path Path represents a path on the storage system to a directory or file. Conceptually it is a replacement for the java.io.File class. Path path = Paths.get(/bla/bli/blu/blue.txt); Paths is the factory class for the interface Path. The  Paths class contains static factory methods that return a Path. […]

OCP

Java IO

Posted on

Yes, there are so many different Stream classes. (Now I am talking about IO Streaming) Here are some tips to keep them apart: All these classes inherit (in)directly from on of the following four abstract Classes InputStream OutputStream Reader Writer ! You cannot instantiate one of the above classes since they are all abstract If […]

OCP

Concurrency: threats or Threads

Posted on

In this post I go over the basis of concurrent execution in Java. I advise you to run the code snippets yourself to get the most out of it. This is an overview, not a tutorial. If you are able to explain the working of the example on the bottom yourself, you have a good […]

OCP

All is good.. except for Exceptions

Posted on

Point Out The Mistakes public class Mistakes { public static void main(String[] args) { try { throwException(); } catch (MissingResourceException e){ } catch (InputMismatchException e | FileNotFoundException e){ } catch (ParseException | ArrayIndexOutOfBoundsException e){ } catch (MissingResourceException | IllegalArgumentException e){ } catch (Throwable e){ } catch (IOException e){ } } private static void throwException() throws […]

OCP

It’s time..

Posted on

Did you know: Month.JANUARY is the same as Month.of(1) Month is an enum Month.JANUARY == 1 does not compile since Month is an enum and enums cannot be compared to an int Month.JANUARY.getValue() returns 1 because getValue is implemented as return ordinal() + 1 ZonedDateTimes can be created from a LocalDate, LocalTime and a ZoneId: LocalDate […]

OCP

Trick Question

Posted on

What is the output of the following code snippet: import java.time.*; public class DaylightSaving { public static void main(String[] args) { LocalDate date = LocalDate.of(2019, Month.MARCH, 31); LocalTime time = LocalTime.of(2,30); LocalDateTime dateTime = LocalDateTime.of(date, time); ZoneId zone = ZoneId.of(“Europe/Paris”); ZonedDateTime zonedDateTime = ZonedDateTime.of(dateTime, zone); System.out.println(zonedDateTime); } } Scroll down..           […]

tech

MongoDB Europe

Posted on

A few weeks ago I had the chance to visit MongoDB Europe. Read about all the features we learned more about in the following blogpost by me and my colleagues: https://ordina-jworks.github.io/development/2018/11/20/mongodb-europe-018.html

OCP

OCP: Functional Programming in Java

Posted on

Java8 revolutionised Java programming with the introduction of functional programming. Here is a little quiz (you ‘ll find the answers below): 1 . What is the name of the abstract method of the Consumer interface? A. apply B. accept C. test D. get   2 . Which method can you call on Optional to perform […]

Python

Python fun!

Posted on

Recently dove into Python and wanted to share the fun!   Playing with the Chuck Norris API and writing chuck quotes to a file: import requests URL = ‘https://api.chucknorris.io/jokes/random’ outFile = ‘chucknorris.html’ open(outFile, ‘w’).close() with open(outFile,’a’) as o: for i in range(1000): json_response = requests.get(URL).json() o.write(‘<h4>’ + json_response[‘value’] + ‘</h4>\n’) print(json_response[‘value’])   Surrounding each line […]