Good exercises once you check the solution and try to go line by line to understand. Like you would do in a class before attempting yourself.
Otherwise, just trying to solve them by yourself it would take crazy amount of time IMO.
My method: first try myself for a while, try at least to generate the pseudo-code, the logic of how it would work.
Then try and write some of the prepcode.
When I get stuck try some googling.
If not successful check solution and see what's different.
Justin SmithLevel 41, Greenfield, USA, United States
30 July 2022
My same process. There have definitely been some where I get stuck and I can't figure out why (like it appears to produce the correct result but won't validate), and then I look at the solution.
Really, these new methods needs at least some examples... it's a little bit frustrating. It's doable, but i find the effort to search and implement the program according to the requirements without examples a little bit too much
found some using the link in the last row, https://docs.oracle.com/javase/tutorial/essential/io/legacy.html
scroll down a bit and "Tutorial Coverage" last column of the API table
I wish the knowledge needed for this excercise were actually taught in the lesson(s) before. We learned about "Path" and "Files", but not about "Paths".
For the "File Downloader" one, don't create a temp directory, only a temp file. I was stuck trying to debug it for almost an hour. And if you are getting "FileAlreadyExistsException", just use REPLACE_EXISTING, on move and copy methods.
Hm... Lesson says:
"It's very simple. Look at this example:
Path tempFile = Files.createTempFile("temp-",".tmp");
Files.copy(inputStream, tempFile);"
I had problem with FileAlreadyExistsException too.
Thank you :)
GO TO FULL VERSION