简体   繁体   中英

Non-blocking file operations in spring-webflux

I need to write some code to manage files for a spring-webflux service. The first instinct is to use File/Files which work fine in a regular app, but they're blocking.

So, I googled most of all criterias I imagined but all results were mostly related to uploading/downloading files.

My question is - is there any way to manage files (delete,copy,move) in a non-blocking fashion under spring-webflux? Even a 3rd party lib?

Java NIO (New IO) is an alternative IO API for Java, meaning alternative to the standard Java IO and Java Networking API's. Parts of the NIO APIs are actually blocking - eg the file APIs - so the label "Non-blocking" would be slightly misleading.

Nevertheless, Java NIO enables you to do non-blocking IO. For instance, a thread can ask a channel to read data into a buffer. While the channel reads data into the buffer, the thread can do something else. Once data is read into the buffer, the thread can then continue processing it. The same is true for writing data to channels.

You can read more about this at:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM