java-8

Nested forEach in Java 8

馋奶兔 提交于 2019-12-25 08:29:34
问题 I want to rewrite this piece of code in terms of streams from Java 8 for (Medium medium : sortierteMedien) { System.out.println("Fuenf aehnlichste Medien fuer " + medium.getClass() + " mit dem Titel " + medium.getTitel() + ":\n"); for (Medium medium1 : bibliothek.medienSim(medium)) { System.out.println(medium1.toString()); } System.out.println(); } The difficulty here is, that there is a print statement before and after each inner for loop. Is it possible to rewrite this with streams? 回答1:

Ambiguous lambda overload in Guava Futures

老子叫甜甜 提交于 2019-12-25 08:21:54
问题 I believe I am facing an eclipse bug here, but I'd like to confirm. I am using java 8 (jdk 1.8.0_102), and my code compiles normally, but eclipse gives me an error. My code looks like this: public ListenableFuture<ProtoBufExchange> myMethod( //some code here return Futures.transform(future,(Request.Builder reqBuilder) -> { //some code here return Futures.immediateFuture(exchange); } The error shown in eclipse is this: The method transform(ListenableFuture<Request.Builder>, AsyncFunction<?

How to serialize a Predicate<T> from Nashorn engine in java 8

纵饮孤独 提交于 2019-12-25 06:50:04
问题 How can i serialize a predicate obtained from java ScriptEngine nashorn? or how can i cast jdk.nashorn.javaadapters.java.util.function.Predicate to Serializable? Here is the case: I have this class import java.io.Serializable; import java.util.function.Predicate; public class Filter implements Serializable { private Predicate<Object> filter; public Predicate<Object> getFilter() { return filter; } public void setFilter(Predicate<Object> filter) { this.filter = filter; } public boolean evaluate

Applets loading very slow on Java 8u 45 with stack overflow error while it works fine with Java 7

牧云@^-^@ 提交于 2019-12-25 06:14:24
问题 I am getting a Stackoverflow error on Java Console while opening the Applets over network on Java Version 8 build 1.8.0_45-b15 . The applet gets loaded but takes around 8 minutes and the same works fine in any of the Java 7 versions over the network . Can anyone please help .. The stacktrace is as follows . java.lang.StackOverflowError at java.security.AccessController.doPrivileged(Native Method) at sun.security.provider.PolicyFile.getPermissions(Unknown Source) at sun.security.provider

Applets loading very slow on Java 8u 45 with stack overflow error while it works fine with Java 7

做~自己de王妃 提交于 2019-12-25 06:14:11
问题 I am getting a Stackoverflow error on Java Console while opening the Applets over network on Java Version 8 build 1.8.0_45-b15 . The applet gets loaded but takes around 8 minutes and the same works fine in any of the Java 7 versions over the network . Can anyone please help .. The stacktrace is as follows . java.lang.StackOverflowError at java.security.AccessController.doPrivileged(Native Method) at sun.security.provider.PolicyFile.getPermissions(Unknown Source) at sun.security.provider

Multiple exception catch block java 8 eclipse

狂风中的少年 提交于 2019-12-25 05:01:29
问题 I'm getting an unhandled message exception for IOException. As you can see in the pasted code I've handled the IOException. The JDK for both eclipse & the project is Java 8 update 121 so I know catching multiple exceptions is supported. What am I doing wrong? try (InputStream inputStream = BatchMessageProperties.class.getClassLoader(). getResourceAsStream(propertiesFileName)) { load(inputStream); //need to make sure all properties are present & not null. validate(this); } catch (IOException |

Multiple exception catch block java 8 eclipse

送分小仙女□ 提交于 2019-12-25 05:01:01
问题 I'm getting an unhandled message exception for IOException. As you can see in the pasted code I've handled the IOException. The JDK for both eclipse & the project is Java 8 update 121 so I know catching multiple exceptions is supported. What am I doing wrong? try (InputStream inputStream = BatchMessageProperties.class.getClassLoader(). getResourceAsStream(propertiesFileName)) { load(inputStream); //need to make sure all properties are present & not null. validate(this); } catch (IOException |

JavaMail from OpenShift: javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted

倾然丶 夕夏残阳落幕 提交于 2019-12-25 03:06:18
问题 I have an application deployed on OpenShift, from which I need to send email to and from a single Google account. With the application deployed locally, it works perfectly; however, when trying the same with the application deployed on OpenShift, I get the following authorisation error: 19:23:16,265 ERROR [stderr] (default task-2) javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at https://support.google.com/mail/answer/14257 wn10sm1673177wjc

Java 7 to Java 8 issue with setting background color of TextArea and StyleSheets/css

浪尽此生 提交于 2019-12-25 02:07:05
问题 I had a Java FXML application functioning in Java 7u51 that I built in NetBeans 7.4. I have installed Java 8 and NetBeans 8. I recreated my little application in Java 8/NetBeans 8. Everything is working except some of the css styling. Specifically, I have a Text Area. Here is the Text Area FXML: <TextArea layoutX="1" layoutY="230" minHeight="120" minWidth="320" editable="false" fx:id="eventWindow" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.bottomAnchor="0.0"/> Here is

Increase in Metaspace with TransformerFactory's XSLT Transformer

僤鯓⒐⒋嵵緔 提交于 2019-12-25 01:41:46
问题 When I run the following code with multiple different requests, the java metaspace is getting increased. public String applyXsltOnXml(String xmlString, String xsltInput) throws TransformerException { String result = null; try (StringReader stringReader = new StringReader(xmlString); StringWriter writer = new StringWriter()) { TransformerFactory factory = TransformerFactory.newInstance(); Transformer transformer = factory.newTransformer(new StreamSource(new StringReader(xsltInput)));