Profile cover photo
Profile photo
Edward Legaspi
72 followers -
If you cannot stand firm on your faith, you can't stand at all.
If you cannot stand firm on your faith, you can't stand at all.

72 followers
About
Posts

Post has attachment

Post has attachment
How to encrypt and decrypt an object in and from a file in Java
There are times when we need to write something on a file, but doesn't want it to be readable as a plain text. In this case we can use any type of encryption mechanism, but what if we want to decrypt the encrypted file back and read its contents. For exampl...
Add a comment...

Post has attachment
How to implement a practical example of Hibernate Search Faceting
With the document available from Hibernate Search (https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#query-faceting), we should be able to implement a faceting example that returns the faceting field and its count. In the example ...
Add a comment...

Post has attachment
How to sort your List in Java using Collator
I often forget this format so I'm blogging it here: Collator descriptionSort = Collator.getInstance();
descriptionSort.setStrength(Collator.PRIMARY);
Collections.sort(entityFacets, Comparator.comparing(f -> f.getDescription(), descriptionSort));
Add a comment...

Post has attachment
Display a byte[] image from a REST web service
This tutorial will not delve into angular nor will we discuss what a directive is. We will not try to explain what a rest web service is. Instead we will provide a demonstration via actual code, how we can consume a rest service from angular that returns an...
Add a comment...

Post has attachment
How to secure an Angular app using AuthGuard with Keycloak
Disclaimer: This is not a tutorial on how to setup an Angular4 project, nor are we going to discuss how to setup a Keycloak server. Needless to say you should already be familiar with Angular4 and Keycloak before diving here. I have a previous article you m...
Add a comment...

Post has attachment
How to download a file in SOAP API
First we define the interface like this: @WebMethod
ActionStatus downloadFile(@WebParam(name = "file") String file); Implementation: public ActionStatus downloadFile(String filePath) {
MessageContext mc = webServiceContext.getMessageContext(); // see http:...
Add a comment...

Post has attachment
How to download a file using REST api
Normally I create an interface when defining a REST api, this is useful when testing using Arquillian. To define a download file api we must define the method below in the interface. @GET
@Path("/downloadFile")
ActionStatus downloadFile(@QueryParam("file") ...
Add a comment...

Post has attachment
How to upload a file in REST API
This is how I define the method: @POST
@Path("/upload")
@Consumes(MediaType.MULTIPART_FORM_DATA)
ActionStatus uploadFile(@MultipartForm FileUploadForm form); And then the implementation: public ActionStatus uploadFile(FileUploadForm form) {
File file = new...
Add a comment...

Post has attachment
How to zipped a file or directory in java
There are times when we have to zipped a file or directory recursively in Java. This is how we do it: public static void zipFile(File file) throws IOException {
byte[] buffer = new byte[1024];

FileOutputStream fos = new FileOutputStream(
file.getParen...
Add a comment...
Wait while more posts are being loaded