New answers tagged

1

Improvements: Java 7 try-with-resources handles closing of all that IO in normal and Exceptional circumstances Skip all lines until i'th. Original code loaded the whole file into memory for no benefit. Safely handle small file (readLine() will return null after the last line) Safely handle short line (vals array may be shorter than j) Written as a utility ...


8

Spaces Your use of spaces could stand improvement. You should have one space after every comma in argument list, and around binary operators. It is also customary to have a space between a closing parenthesis and an opening brace. Names Use descriptive names! Is r1 a method name, or a BufferedReader? Why are these named the same, anyway? What is ...


1

I honestly think you should be breaking up the treatment of the file into two parts, as you are already (implicitly) doing so in your function. One part to read the file into a line iterator, another to actually parse. The "reading into an iterator" is a simple combination of std::fs::File::read_line; I'll instead focus on the other part: pub fn ...


Top 50 recent answers are included