Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 5B2FBDF0B for ; Tue, 28 May 2013 05:46:06 +0000 (UTC) Received: (qmail 21591 invoked by uid 500); 28 May 2013 05:46:00 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 21421 invoked by uid 500); 28 May 2013 05:45:59 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 21025 invoked by uid 99); 28 May 2013 05:45:52 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 May 2013 05:45:52 +0000 Date: Tue, 28 May 2013 05:45:50 +0000 (UTC) From: "Peter B. (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (IO-376) FileUtils.copyFile for the locked file (windows) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/IO-376?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13668107#comment-13668107 ] Peter B. edited comment on IO-376 at 5/28/13 5:45 AM: ------------------------------------------------------ I got it solved by slightly modified solution described in: http://mohammed-technical.blogspot.de/2011/02/how-to-read-file-without-locking-in.html as the guy reads only byte by byte, where I read to buffer to speed up things up to RandomAccessFile.length(). Moreover as I already mentioned, similar functionality is already present in the: http://commons.apache.org/proper/commons-io/javadocs/api-2.4/org/apache/commons/io/input/Tailer.html so it should not be such a big deal. was (Author: typek_pb): I got it solved by slightly modified solution described in: http://mohammed-technical.blogspot.de/2011/02/how-to-read-file-without-locking-in.html as he reads only byte by byte, where I read to buffer to speed up things up to RandomAccessFile.length(). Moreover as I already mentioned, similar functionality is already present in the: http://commons.apache.org/proper/commons-io/javadocs/api-2.4/org/apache/commons/io/input/Tailer.html so it should not be such a big deal. > 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