This question is meant as a general question, but it is also specifically about this specific question:
It is known that only your own written code are on-topic on this site. However, as programming sometimes is to take some pieces of code from different places and put it together, I am wondering: What does it take to make some code that you have found somewhere "your own"?
As an example, if the specific question above would change the identifier names (parameters and method name), use a different indenting, another kind of exception thrown, etc. Could then the code be called "my own"? (and the question possibly re-opened) Because there is really no other structural different way of doing what is done in that code (except following the guidelines from my answer of course).