How can I read all files in a folder from Java?

Use: public void listFilesForFolder(final File folder) { for (final File fileEntry : folder.listFiles()) { if (fileEntry.isDirectory()) { listFilesForFolder(fileEntry); } else { System.out.println(fileEntry.getName()); } } } final File folder = new File(“/home/you/Desktop”); listFilesForFolder(folder); The Files.walk API is available from Java 8. try (Stream<Path> paths = Files.walk(Paths.get(“/home/you/Desktop”))) { paths .filter(Files::isRegularFile) .forEach(System.out::println); } The example uses the try-with-resources … Read more

The difference between InputStream and InputStreamReader when reading multi-byte characters

An InputStream reads raw octet (8 bit) data. In Java, the byte type is equivalent to the char type in C. In C, this type can be used to represent character data or binary data. In Java, the char type shares greater similarities with the C wchar_t type. An InputStreamReader then will transform data from … Read more

What exactly is io_uring?

io_uring is a (new as of mid 2019) Linux kernel interface to efficiently allow you to send and receive data asynchronously. It was originally designed to target block devices and files but has since gained the ability to work with things like network sockets. Unlike something like epoll(), it is built around a completion model … Read more

Python code performance decreases with threading

This is sadly how things are in CPython, mainly due to the Global Interpreter Lock (GIL). Python code that’s CPU-bound simply doesn’t scale across threads (I/O-bound code, on the other hand, might scale to some extent). There is a highly informative presentation by David Beazley where he discusses some of the issues surrounding the GIL. … Read more

Modern C++ idiom for allocating / deallocating an I/O buffer

Basically, you have two main C++-way choices: std::vector std::unique_ptr I’d prefer the second, since you don’t need all the automatic resizing stuff in std::vector, and you don’t need a container – you need just a buffer. std::unique_ptr has a specialization for dynamic arrays: std::unique_ptr<int[]> will call delete [] in it’s destructor, and will provide you … Read more

Accept user input

GHJUYGHJKLKUJHM;&MJ:6AG9F5D8V)A8%]>75Q;6EE85U955%-245!/3DU,2TI) M2$=&141#0D% /SX]/#LZ.3@W-C4T,S(Q,”\N+2PK*BDH)R8E)”,B(7Y]?’MZ M>7AW=G5T<W)Q<&]N;6QK:FEH9V9E9&-B86!?7EU<6UI96%=655134E%03TY- Untested, but should work.