GithubHelp home page GithubHelp logo

sheikhimtiaz / java-workshop Goto Github PK

View Code? Open in Web Editor NEW

This project forked from josdem/java-workshop

0.0 1.0 0.0 318 KB

Coding examples showing solutions to common Java project applications

Java 84.15% Groovy 15.85%

java-workshop's Introduction

CSV Transformer

How to read and write a CSV file using Apache Commons CSV

Read this as reference

To run the project

gradle test

Date And Time

A quick review to the java.util.Date API in Java 8

Read this as reference

To run the project

javac BetweenDays.java
java BetweenDays

javac DateOperations.java
java DateOperations

Excel Reader

How to read an Excel file using Apache POI

Read this as reference

To run the project

gradle test

Excel Filter Reader

How to read filtered rows in Excel file using Apache POI

Read this as reference

To run the project

gradle test

Hello AWS Lambda

Hello World using AWS Lambda

Read this as reference

To build the project

gradle buildJar

Java NIO Copy

Since Java 7 we can copy files in a easy way

Read this as reference

To build the project

javac FileCopier.java
java FileCopier

Properties Apache Commons

Generic configuration interface which enables a Java application to read configuration data

Read this as reference

To build the project

gradle buildJar

To run the project

java -jar properties-apache-commons-all-0.0.1.jar

S3 AWS Lambda

Read and copy files using AWS Lambda

Read this as reference

To build the project

gradle buildZip

To invoke the project

aws lambda invoke \
--invocation-type Event \
--function-name s3-aws-lambda \
--region us-west-1 \
--payload file://inputfile.txt \
outputfile.txt

Mailbox Reader

Configuration

In your computer's home directory: ${home}, create a directory called: .mailbox-reader then inside create a file called application.properties with this content

username[email protected]
password=secret
pop3.server=pop.gmail.com
pop3.port=995
imap.server=imap.gmail.com
imap.port=993
ews.username[email protected]
ews.password=secret
ews.server=https://exchange/EWS/Exchange.asmx
ews.protocol=https://

Build

gradle build

Run

 java -jar mailbox-reader-0.0.1-SNAPSHOT.jar

Features

  • This approach is using Gmail account with IMAP enabled (Settings > Forwarding and POP/IMAP)
  • Using Exchange Web Services EWS Java API
  • Read body email usgin text/plain as ContentType
  • Read body email using multipart/mixed as ContenType

Read this as reference

Stream

Stream interface is defined in java.util.stream package. In Java 8, collections will start having methods that return Stream. Streams support Aggregate Operations. The common aggregate operations are filter, map, reduce, find, match and sort.

Read this as reference

To build the project

javac ${JAVA_PROGRAM}.java
java -ea ${JAVA_PROGRAM}

Stream Filters

A stream represents a sequence of elements and supports different operations to perform calculations in those elements, here we review the filters:

Read this as reference

To build the project

javac ${JAVA_PROGRAM}.java
java -ea ${JAVA_PROGRAM}

Stream Collectors

How use collectors over streams to group by, concatenate, map and list.

Read this as reference

To run the project

javac ${JAVA_PROGRAM}.java
java -ea ${JAVA_PROGRAM}

Executors

How use Executors, Callable and Futures

Read this as reference

To run the project

javac ${JAVA_PROGRAM}.java
java ${JAVA_PROGRAM}

Generics

How we can use Generics in Java.

Read this as reference

To run the code:

javac ${JAVA_PROGRAM}.java
java -ea ${JAVA_PROGRAM}

To test the code:

gradle test

Functional Interfaces

A functional interface in Java is any with @FunctionalInterface annotation and with SAM(Single Abstract Method). It was introduced to facilitate Lambda expressions. Since a lambda function can only provide the implementation for one method, it is mandatory for the functional interfaces to have only one abstract method.

Read this as reference

To run the code

javac ConsumerExample.java
java ConsumerExample

To test the code using Gradle

gradle test

To test the code using Maven

mvn test

Lambda Expressions

Since Java 8 we have Lambda expressions which is a function defined under some interface contract and the main purpose is to implement functional programming in Java.

Read this as reference

To test the code using Gradle

gradle test

To test the code using Maven

mvn test

Using Optional

Once called a Billion-dollar mistake. NullPointerException is by far one of the most frequent exceptions in Java and since version 8 we can use it as a way to avoid this exception. Optional is a container that can has a value or not.

Read this as reference

To test

gradle test

java-workshop's People

Contributors

josdem avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.