Questions tagged as 'java-8'

1
answer

How to run DOS command in JAVA with Administrator privilege?

Hello, I have a program where I need every run of it, go to the server, pick date and time, and change it on the local PC. I am running the following command line: Runtime.getRuntime().exec('DATE '+dataServidor.trim()); and JAVA returns...
asked by 24.11.2017 / 14:47
2
answers

How to do every time you pass "true", does it print the entire instantiated object?

import java.util.ArrayList; public class Loja { private ArrayList<Produto> ListaDeProdutos = new ArrayList<>(); /* private ArrayList<Livro> ListaDeLivros = new ArrayList<>(); private ArrayList<Disco> Li...
asked by 14.09.2018 / 14:48
2
answers

Move file list between folders

I have a method that copies files from one folder to another, deleting the file then. It even caters me perfectly, but I would like to know if there is any way to do this without having to use InputStream and OutputStream , since I...
asked by 30.11.2016 / 13:33
2
answers

Doubts about using the Java 8 stream

I'm practicing some new things that came with Java 8 and among those using Stream. I have heard in a place that when we do some action in a list using the stream, it does not change the value of the original list, for example: List<String&g...
asked by 03.06.2015 / 13:57
1
answer

How to use Java 8 stream in an Object list []

Imagine the following scenario: A list of Object[] . Something similar to this: List<Object[]> lista = new ArrayList<>(); Object[] dados = new Object[3]; dados[0] = 1; dados[1] = 20; dados[1] = "cristiano"...
asked by 05.09.2017 / 20:47
1
answer

Lambda expressions in nested classes with multiple methods

I was reading about lambdas and out of curiosity, I wanted to know why it is not allowed to use when the class / interface has more than one method, which forces us to do things like below: component.addMouseListener(new MouseListener() {...
asked by 12.07.2017 / 15:13
2
answers

Business days and API Java 8, how to check?

How to check if a day is useful using the Java 8 API? It is possible to check if it is Saturday or Sunday, but how to check for example holiday like September 7 (Independence of Brazil) or Good Friday? int ano = 2014; int mes = 5; YearMonth an...
asked by 30.07.2018 / 20:25
2
answers

Search for information in the database with Hibernate parameter validation

Analyze the following situation: request will provide country information that can be {0, 1, 2} . The repository method will look like this: Country Parameter Naming: 0: Bring all countries; 1: National only (Brazil) 2: Internat...
asked by 15.08.2018 / 16:30
1
answer

How to turn a number reading directly into stream?

Recently I wrote a response by exploring Java's stream API a bit more, but I should say that I was disappointed with some details of my code. The idea was to read a sequence of numbers and then return the highest and lowest value of...
asked by 27.03.2018 / 04:36
2
answers

How to implement a class to use PreparedStatement through it?

I have the following class Connects.java package util; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; import java.sql.Statement; public class Conecta { //Pode...
asked by 20.03.2017 / 02:03