1
1
1010101010102015-11-16 13:29:05
Java
101010101010, 2015-11-16 13:29:05

How to determine the end of copying a file to the file system?

there is a function that copies a file from a temporary directory

try(OutputStream outputStream = new FileOutputStream(new File(fileFullPath));){
            int read = 0;
            byte[] bytes = new byte[1024];
            while ((read = is.read(bytes)) != -1) {
                outputStream.write(bytes, 0, read);
            }
            outputStream.flush();
        } catch (IOException e) {
            logger.error(e.getMessage(), e);
        }

the problem is that after copying the file needs to be transferred over the network. But the file is transferred correctly only when debugging is enabled, i.e. it is very likely that the transfer starts before the file is completely copied. Has anyone come across this problem and knows how to solve it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dekker8, 2015-12-31
@Dekker8

well, after executing the while loop, when the file is read, call the function of copying it from the network, maybe I didn’t understand the question correctly ((((

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question