posted 3 days ago
I realised reading a file into bytes-array with next writing this array to file in another directory by the following approach:
And this code done well - in target directory appear new file with the relevant content (for example: "abcd").
Further I tried to improve my approach through ApacheCommons abilities.
But this approach entails the problem: in target directory the new file appeals, but this written content is irrelevant. Besides the written text (for example: "abcd") it contains some unreadable unencoded symbols, and I see the warning about problem with encoding.
I suppose this problem is related to the fact, that some excess bytes read and/or write to OutpumStream. And this problem (probably) arise due to the fact I don't restrict read and write-operations, applying IOUtils (second approach).
And in first approach I restrict the write of byte-array in OutputStream by size of length-variable:
If problem in that I must have a way to restrict the write by tools of AppacheCommons.
But I don't see any way to do so in IOUtils-methods.