New answers tagged

5

Exception Handling What are you doing in the exceptional case? Printing an error message (ugly stack trace, actually) and returning null. Now the caller has to handle the problem of the function returning null. You've said: I don't need error-handling except that I know I provided the wrong path. Well, want is the caller doing when it gets the null? ...


3

Since you are handling the file in the same method of the extraction, you have to deal with the exception. I suggest that you separate the logic of the file reading and the logic of the parsing in two separate methods, so the method that handles the file will handle the exception. public static Stream<String> readFileAsLines(final String filePath) { ...


0

This is based on deuberger's answer, just a little shorter import logging from threading import Thread import os import subprocess from contextlib import contextmanager logging.basicConfig(format='%(levelname)s:%(message)s', level=logging.INFO) @contextmanager def logpipe(level): fd_read, fd_write = os.pipe() def run(): with os.fdopen(...


2

in my opinion, the code is good, but I have some suggestions. com.github.coderodde.RemoteFile class com.github.coderodde.RemoteFile#download(java.io.File) The URISyntaxException in the method com.github.coderodde.RemoteFile#download(java.io.File) is never thrown and can be removed. In my opinion, the logic of this method should be extracted to an external ...


Top 50 recent answers are included