Pular para o conteúdo principal

Postagens

Mostrando postagens com o rótulo java 8

QuickPost: Object to CSV using Java 8

In a personal application I wanted to transform a few classes to CSV format without having to use external libraries. I used Java 8 and it is working very well for me so I thought about share the class in this post. It basically goes through the fields of a given class from a List and creates the CSV. The same case could be applied for XML, JSON and other formats, but in my case I only needed CSV. The original version had only a few lines, but I increased it to include a few configuration fields. See the class and a simply JUnit test for it. The source code of the maven project is also in my github .

Writing JavaFX apps using Javascript with the Java 8 Nashorn engine

Java 8 was just a great release! We already talked about Lambdas and created JavaFX 8 apps on this blog. Bruno Borges created a fx2048 , a JavaFX version of the famous 2048 game, which shows Lambdas and the Stream library usage. Today I'll rewrite the Sentiments App view in Javascript using the new JS engine named Nashorn , one of the exciting Java 8 new features. Loading the Script We load a file with the view contents, but before doing this, we add the main Stage so it can be referenced from the javascript file. That's enough for the Java part! package org.jugvale.sentiments.view; import javafx.application.Application; import javafx.stage.Stage; import javax.script.*; import java.io.FileReader; public class AppJS extends Application{ private final String SCRIPT = getClass().getResource("/sentimentsView.js").getPath(); public static void main(String args[]){ launch(args); } @Override public voi...

Having fun creating a JavaFX App to Visualize Tweet Sentiments

A cool think that people loves to do is to create apps that analyze the sentiment of some text stream, such as Twitter. To better understand, see a graphical sentiment analysis for the Java 8 release messages on Twitter ( source ): In this post, I'm going to create a simple, really simple, app that queries twitter, and then access the Sentiment140 REST API to analyze the tweet's content sentiment. After this, I'll count the results in a chart and also list the text content in a table. Using the Sentiment140 REST API The API is really simple to use. Since I'm lazy, I love simplicity. To use it, submit a text and it will return a simple JSON with a number value called polarity, which possible values are: 0: negative 2:  neutral 4: positive The API documentation contains all the information you need to use it. Again, I simply loved how easy is to use it. For example, if I want to submit the text "I Love REST APIs" to the API, I would have to HTTP...