You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Peter B. (JIRA)" <ji...@apache.org> on 2013/04/15 09:54:16 UTC

[jira] [Updated] (IO-376) FileUtils.copyFile for the locked file (windows)

     [ https://issues.apache.org/jira/browse/IO-376?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Peter B. updated IO-376:
------------------------

    Description: 
The use case:
- log4j writes to the file using RollingFileAppender.
- in parallel I need to read the file contents for later manipulation (storing it's contents elsewhere)

Problem on windows:
- I open FileInputStream for reading from file
- when using IOUtils.copy(InputStream input, OutputStream output) exception is thrown:
{code} 
java.io.IOException: The process cannot access the file because another process has locked a portion of the file
{code} 

It would be great to have API enabling to copy contents of the locked file (on windows) to OutputStream.

The method available in the API currently:
{code:java} 
FileUtils.copyFile(File input, OutputStream output)
{code} 

does the job, except for the files that are locked (in the windows environment) as they're currently written to.

Some of the functionality is already in use in the: Tailer

However (non-bloked) copying full contents is not provided.
I'd need to retrieve a snapshot of the file.

Not sure about the right API, but generally I see 2 options:
- custom (File)InputSteam implementation or maybe
- custom FileUtils.copyFile(File input, OutputStream output)

  was:
The use case:
- log4j writes to the file using RollingFileAppender.
- in parallel I need to read the file contents for later manipulation (storing it's contents elsewhere)

Problem on windows:
- I open FileInputStream for reading from file
- when using IOUtils.copy(InputStream input, OutputStream output) exception is thrown:
java.io.IOException: The process cannot access the file because another process has locked a portion of the file

It would be great to have API enabling to copy contents of the locked file (on windows) to OutputStream.

The method available in the API currently:
copyFile(File input, OutputStream output)

does the job, except for the files that are locked (in the windows environment) as they're currently written to.

Some of the functionality is already in use in the: Tailer

However (non-bloked) copying full contents is not provided.
I'd need to retrieve a snapshot of the file.

Not sure about the right API, but generally I see 2 options:
- custom (File)InputSteam implementation or maybe
- custom FileUtils.copyFile(File input, OutputStream output)

    
> FileUtils.copyFile for the locked file (windows)
> ------------------------------------------------
>
>                 Key: IO-376
>                 URL: https://issues.apache.org/jira/browse/IO-376
>             Project: Commons IO
>          Issue Type: New Feature
>          Components: Streams/Writers
>    Affects Versions: 2.4
>         Environment: Windows
>            Reporter: Peter B.
>            Priority: Minor
>
> The use case:
> - log4j writes to the file using RollingFileAppender.
> - in parallel I need to read the file contents for later manipulation (storing it's contents elsewhere)
> Problem on windows:
> - I open FileInputStream for reading from file
> - when using IOUtils.copy(InputStream input, OutputStream output) exception is thrown:
> {code} 
> java.io.IOException: The process cannot access the file because another process has locked a portion of the file
> {code} 
> It would be great to have API enabling to copy contents of the locked file (on windows) to OutputStream.
> The method available in the API currently:
> {code:java} 
> FileUtils.copyFile(File input, OutputStream output)
> {code} 
> does the job, except for the files that are locked (in the windows environment) as they're currently written to.
> Some of the functionality is already in use in the: Tailer
> However (non-bloked) copying full contents is not provided.
> I'd need to retrieve a snapshot of the file.
> Not sure about the right API, but generally I see 2 options:
> - custom (File)InputSteam implementation or maybe
> - custom FileUtils.copyFile(File input, OutputStream output)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira