Instantly share code, notes, and snippets.

View CalculadoraDePrecos.java
public class CalculadoraDePrecos {
public static BigDecimal calcula(Sessao sessao, Integer quantidade) {
return sessao.calcula(quantidade);
}
}
View FileUtils.java
package br.com.paradizo.tema;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.FileSystem;
import java.nio.file.FileSystemAlreadyExistsException;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
View FileUtils.java
public class FileUtils {
public static String getResourceContents(String resource) throws URISyntaxException, IOException {
Path resourcePath = getResourceAsPath(resource);
return getPathContents(resourcePath);
}
private static Path getResourceAsPath(String resource) throws URISyntaxException, IOException {
URI uri = FileUtils.class.getResource(resource).toURI();
View JacksonConfig.java
@Configuration
public class JacksonConfig {
@Bean
public ObjectMapper objectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.setVisibility(PropertyAccessor.GETTER, Visibility.NONE);
mapper.setVisibility(PropertyAccessor.SETTER, Visibility.NONE);
mapper.setVisibility(PropertyAccessor.CREATOR, Visibility.NONE);
mapper.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
View .bashrc
#show java version on prompt
current_sdk_java_version() {
export PS1="\e[0;32m$(sdk current java version | grep version | sed -e 's/.*version \(.*\)/\1/')\e[m$ "
}
PROMPT_COMMAND="current_sdk_java_version"
View EscapeXmlELResolverListener.java
package br.com.caelum.fj91.seguranca;
import java.beans.FeatureDescriptor;
import java.util.Iterator;
import javax.el.ELContext;
import javax.el.ELResolver;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.jsp.JspContext;
View show-module-resolution.txt
root jdk.management.jfr jrt:/jdk.management.jfr
root jdk.jdi jrt:/jdk.jdi
root javafx.web jrt:/javafx.web
root jdk.xml.dom jrt:/jdk.xml.dom
root jdk.jfr jrt:/jdk.jfr
root jdk.packager.services jrt:/jdk.packager.services
root jdk.httpserver jrt:/jdk.httpserver
root javafx.base jrt:/javafx.base
root jdk.net jrt:/jdk.net
root javafx.controls jrt:/javafx.controls
View 2017-11-22.log
alexandre ~/keyword $ /usr/lib/jvm/java-8-oracle/bin/javac Keyword.java
Keyword.java:3: warning: '_' used as an identifier
int _ = 1;
^
(use of '_' as an identifier might not be supported in releases after Java SE 8)
Keyword.java:4: warning: '_' used as an identifier
System.out.println(_);
^
(use of '_' as an identifier might not be supported in releases after Java SE 8)
2 warnings
View MedicaoDeTempoFilter.java
package br.com.caelum.tarefas.filters;
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;