Practice using File
Comments (22)
- Popular
- New
- Old
You must be signed in to leave a comment
Hoist
2 June 2023, 02:41
https://codegym.cc/help/14564
0
Hoist
2 June 2023, 00:29
Closer. Detailed HELP discussion.
https://codegym.cc/help/13767
0
Justin Smith
30 July 2022, 13:35
This is an interesting set of three tasks. Three different ways to get a file tree structure. They assume you'll use recursion for the first one, the second explicitly says not to use recursion (use a queue instead), and the third (and IMO superior) option is to use FileVisitor. Learned a lot here!
0
Lisa L
16 May 2022, 13:13
When creating the destiniation file, do not use the File constructor taking two arguments (new File(resultFileAbsolutePath, "allFilesContent.txt")). Validation will not accept it... lots of red until changed. You have to use new File(resultFileAbsolutePath.getParent() + "/allFilesContent.txt"); // getParentFile() instead of getParent() works as well
For the output... you have to create an output stream the usual way. Files.newOutputStream(dest) is not accepted. But you can use Files.copy(path, outStream); to copy the content of each file (just don't forget to add the \n)
+2
Hoist
11 June 2023, 00:23
Level 47 --- unfair ; lol
0
Fadi Alsaidi
6 February 2022, 16:27
I don't get this approach of CodeGYM sometimes??!!! either directly say read about a certain API ,like they used to do in the past, or flat out say don't' use such and such technics, like don't use recursion to travers through the subdirectories. Also, Anyone here can give us an advice on how to find a good API to resolve an issue besides asking in stackoverflow?
+3
Gellert Varga
14 January 2022, 17:57
Task-3101:
1) The file "/allFilesContent.txt" must be on the same path as args[1].
2) File renaming is a critical operation. First check if "/allFilesContent.txt" already exists on disk, and if so delete it, and only then rename the first file.
3) It is mandatory to use the methods in the FileUtils CG class.
4) This rename operation should be at the very beginning of the program, do nothing else before.
5.) All subfolders of args[0] and all their subfolders must be explored, no matter how deep the directory structure.
6) Do not use PrintStream to write to the target file, they will not accept it. CG will only accept FileOutputStream.
7) It is safer to put the entire write operation in a try-catch block.
8) write "\n" == write(10) . (The ASCII code of the line-feed is 10.)
Unfortunately I had 19 attempts; I wish you have less!:)
+4
Lisa
17 November 2021, 21:27
Java IO NIO and NIO.2 (Jeff Friesen), chapter 12: Improved File System Interface
Everything explained here in detail. Recommended reading for these and the following few tasks.
+4
Gellert Varga
3 January 2022, 22:11
Thanks for the useful recommendation!
0
TheLordJackMC a person at war with my demons
6 August 2021, 14:21
hey guys, im completeing every task in one or two attempts, but the average attempt score just keets changing randomly. is this a bug?
0
John Squirrels Website Admin at CodeGym
7 August 2021, 08:50
This average can be very different from one task to another. That's normal.
0
Jurij Thmsn
8 May 2021, 14:44
Iterating through a file tree:
make sure to to
first rename the file
second sorting(etc.)
If you do it in the order as requested in the Conditions, Validation will fail.
0
Romain
5 March 2021, 09:43
Advanced file search
Only 184 students passed it ! 😱
+2
MaGaby2280
3 May 2021, 23:33
212 now 🙃😜
+3