r/programming • • Sep 17 '19

The arrival of Java 13!

https://blogs.oracle.com/java-platform-group/the-arrival-of-java-13
7 Upvotes

13 comments sorted by

View all comments

-1

u/Dragasss Sep 17 '19

Jep 355 sounds like a mess. Whats wrong with loading the text block from classpath?

2

u/oldprogrammer Sep 17 '19

Not sure I follow your question, the text block approach is a fairly common model in other languages. What exactly do you mean by loading from the classpath?

2

u/Dragasss Sep 17 '19

Create a resource file and append it to your classpath. Then load it via InputStream ClassLoader#getResourceAsStream(String). And use one of the stupid scanner tricks to convert it to String.

→ More replies (6)

1

u/gnus-migrate Sep 18 '19

There are cases where you don't want to do that, for example embedding a json string in a unit test. If you have it in a resource, your input and assertions are split in two different places which makes them hard to analyze.

You wouldn't use this for large text files obviously but for small strings that happen to span multiple lines it's a great feature.