You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Stephen Colebourne (JIRA)" <ji...@apache.org> on 2008/01/06 12:08:34 UTC

[jira] Created: (IO-153) FileWriter that accepts an encoding

FileWriter that accepts an encoding
-----------------------------------

                 Key: IO-153
                 URL: https://issues.apache.org/jira/browse/IO-153
             Project: Commons IO
          Issue Type: New Feature
          Components: Streams/Writers
            Reporter: Stephen Colebourne
            Priority: Minor
             Fix For: 1.4
         Attachments: io-FileWriterWithEncoding.patch

Amazingly, even in JDK6 there are no constructors on FileWriter that accept an encoding.

Attached is a patch to add FileWriterWithEncoding

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (IO-153) FileWriter that accepts an encoding

Posted by "Stephen Colebourne (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IO-153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12557174#action_12557174 ] 

Stephen Colebourne commented on IO-153:
---------------------------------------

I've checked this, and I'm happy. Thanks.

> FileWriter that accepts an encoding
> -----------------------------------
>
>                 Key: IO-153
>                 URL: https://issues.apache.org/jira/browse/IO-153
>             Project: Commons IO
>          Issue Type: New Feature
>          Components: Streams/Writers
>            Reporter: Stephen Colebourne
>            Priority: Minor
>             Fix For: 1.4
>
>         Attachments: FileWriterWithEncoding.java, io-FileWriterWithEncoding.patch
>
>
> Amazingly, even in JDK6 there are no constructors on FileWriter that accept an encoding.
> Attached is a patch to add FileWriterWithEncoding

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (IO-153) FileWriter that accepts an encoding

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IO-153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12556459#action_12556459 ] 

Niall Pemberton commented on IO-153:
------------------------------------

Your're right the dummy object isn't using it as designed so probably not a good idea and it doesn't change how it works anyway so not worth arguing over (sorry!). How about you commit what you have - if that includes the Charset etc. stuff great, if not I'll modify it after.

> FileWriter that accepts an encoding
> -----------------------------------
>
>                 Key: IO-153
>                 URL: https://issues.apache.org/jira/browse/IO-153
>             Project: Commons IO
>          Issue Type: New Feature
>          Components: Streams/Writers
>            Reporter: Stephen Colebourne
>            Priority: Minor
>             Fix For: 1.4
>
>         Attachments: FileWriterWithEncoding.java, io-FileWriterWithEncoding.patch
>
>
> Amazingly, even in JDK6 there are no constructors on FileWriter that accept an encoding.
> Attached is a patch to add FileWriterWithEncoding

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (IO-153) FileWriter that accepts an encoding

Posted by "Stephen Colebourne (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IO-153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12556430#action_12556430 ] 

Stephen Colebourne commented on IO-153:
---------------------------------------

* The non-encoding parameters exist as I copied it from LocakbleFileWriter. While it could be argued that having the constructors allows a single class to be used for all purposes, I think that removing the no-encoding constructors is probably sensible.
* The constructor uses file.getAbsolutePath() for JDK1.3 compatability.
* I'm not sure that anything is gained by subclassing ProxyWriter (in fact it is more complex) - what we really want is to subclass FileWriter, but I can't see a way to do that.
* I wanted this to be JDK1.3 compatible. I would hope that the next release will be Java 5 after all ;-)


> FileWriter that accepts an encoding
> -----------------------------------
>
>                 Key: IO-153
>                 URL: https://issues.apache.org/jira/browse/IO-153
>             Project: Commons IO
>          Issue Type: New Feature
>          Components: Streams/Writers
>            Reporter: Stephen Colebourne
>            Priority: Minor
>             Fix For: 1.4
>
>         Attachments: FileWriterWithEncoding.java, io-FileWriterWithEncoding.patch
>
>
> Amazingly, even in JDK6 there are no constructors on FileWriter that accept an encoding.
> Attached is a patch to add FileWriterWithEncoding

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (IO-153) FileWriter that accepts an encoding

Posted by "Stephen Colebourne (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IO-153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12556457#action_12556457 ] 

Stephen Colebourne commented on IO-153:
---------------------------------------

I was simply trying to avoid JDK1.4 if possible, until the jump to 1.5. Personally, I use 1.5, so I'll go with the 1.4 for new classes approach.

On ProxyWriter, I find the use of any dummy objects confusing, and try to use classes as they were designed. However, if you want to check in your version, I'm certainly not going to block it, its simply not the approach I would choose.

> FileWriter that accepts an encoding
> -----------------------------------
>
>                 Key: IO-153
>                 URL: https://issues.apache.org/jira/browse/IO-153
>             Project: Commons IO
>          Issue Type: New Feature
>          Components: Streams/Writers
>            Reporter: Stephen Colebourne
>            Priority: Minor
>             Fix For: 1.4
>
>         Attachments: FileWriterWithEncoding.java, io-FileWriterWithEncoding.patch
>
>
> Amazingly, even in JDK6 there are no constructors on FileWriter that accept an encoding.
> Attached is a patch to add FileWriterWithEncoding

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (IO-153) FileWriter that accepts an encoding

Posted by "Stephen Colebourne (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IO-153?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stephen Colebourne updated IO-153:
----------------------------------

    Attachment: io-FileWriterWithEncoding.patch

Class and test case

> FileWriter that accepts an encoding
> -----------------------------------
>
>                 Key: IO-153
>                 URL: https://issues.apache.org/jira/browse/IO-153
>             Project: Commons IO
>          Issue Type: New Feature
>          Components: Streams/Writers
>            Reporter: Stephen Colebourne
>            Priority: Minor
>             Fix For: 1.4
>
>         Attachments: io-FileWriterWithEncoding.patch
>
>
> Amazingly, even in JDK6 there are no constructors on FileWriter that accept an encoding.
> Attached is a patch to add FileWriterWithEncoding

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (IO-153) FileWriter that accepts an encoding

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IO-153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12556438#action_12556438 ] 

Niall Pemberton commented on IO-153:
------------------------------------

On the JDK 1.3 compatibility the majority agreed with moving to JDK 1.4 for the IO 1.4 release (see IO-127) - however we haven't actually done that, but instead retained JDK 1.3 compatibility for all but three (and this would be a fourth) new implementations. I could understand it i it for this implementation if it was just the FileOutputStream constructor, which gains nothing from using it - but theres an opportunity to support the new Charset and CharsetEncoder features in this impl - so I think we should do that.

I don't understand you saying that using ProxyWriter is more complex - doing so removes the need for the writer variable and the following seven methods:
  - write(int)
  - write(char[])
  - write(char[], int, int)
  - write(String)
  - write(String, int, int)
  - flush()
  - close()

...and replaces that with a "dummy" object in the super constructor and initializing one additional variable (i.e. "lock") - how is that more complex?

Another point is that JDK 1.5 introduces new append() methods in JDK 1.5 which I suggested we should add to ProxyWriter when we move to JDK 1,5 (see IO-140) - which with no effort this impl. would inherit - although maybe delegating to the proxy's append() methods compared to letting the default Writer append methods (which call write()) is a minor point. The main one is no duplicating code around. 

> FileWriter that accepts an encoding
> -----------------------------------
>
>                 Key: IO-153
>                 URL: https://issues.apache.org/jira/browse/IO-153
>             Project: Commons IO
>          Issue Type: New Feature
>          Components: Streams/Writers
>            Reporter: Stephen Colebourne
>            Priority: Minor
>             Fix For: 1.4
>
>         Attachments: FileWriterWithEncoding.java, io-FileWriterWithEncoding.patch
>
>
> Amazingly, even in JDK6 there are no constructors on FileWriter that accept an encoding.
> Attached is a patch to add FileWriterWithEncoding

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (IO-153) FileWriter that accepts an encoding

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IO-153?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Niall Pemberton resolved IO-153.
--------------------------------

    Resolution: Fixed
      Assignee: Stephen Colebourne

> FileWriter that accepts an encoding
> -----------------------------------
>
>                 Key: IO-153
>                 URL: https://issues.apache.org/jira/browse/IO-153
>             Project: Commons IO
>          Issue Type: New Feature
>          Components: Streams/Writers
>            Reporter: Stephen Colebourne
>            Assignee: Stephen Colebourne
>            Priority: Minor
>             Fix For: 1.4
>
>         Attachments: FileWriterWithEncoding.java, io-FileWriterWithEncoding.patch
>
>
> Amazingly, even in JDK6 there are no constructors on FileWriter that accept an encoding.
> Attached is a patch to add FileWriterWithEncoding

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (IO-153) FileWriter that accepts an encoding

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/IO-153?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Niall Pemberton updated IO-153:
-------------------------------

    Attachment: FileWriterWithEncoding.java

I have a few comments/questions:

 - I don't understand why encoding is optional and there are four constructors without an encoding parameter. To use the default encoding people could/should just use FileWriter directly rather than this impl
 - Why not use the FileOutputStream constructor which takes a File rather than passing file.getAbsolutePath() to its String constructor?
 - We could use ProxyWriter and pass a dummy lock/writer to the constructor and reset "lock" and "out" (protected) variables after calling super
 - This only deals with String characterset names - would be good to provide Charset and CharsetEncoder constructors as well. I realize these require JDK 1.4 - but we already have three JDK 1.4 dependant implementations in this release.

Attaching a suggested alternative version with the above points. Currently only has "File" constructors - may want to add String file name constructors as well for convenience.

> FileWriter that accepts an encoding
> -----------------------------------
>
>                 Key: IO-153
>                 URL: https://issues.apache.org/jira/browse/IO-153
>             Project: Commons IO
>          Issue Type: New Feature
>          Components: Streams/Writers
>            Reporter: Stephen Colebourne
>            Priority: Minor
>             Fix For: 1.4
>
>         Attachments: FileWriterWithEncoding.java, io-FileWriterWithEncoding.patch
>
>
> Amazingly, even in JDK6 there are no constructors on FileWriter that accept an encoding.
> Attached is a patch to add FileWriterWithEncoding

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (IO-153) FileWriter that accepts an encoding

Posted by "Niall Pemberton (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/IO-153?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12556818#action_12556818 ] 

Niall Pemberton commented on IO-153:
------------------------------------

OK I've applied your patch with the JDK 1.4 modifications (and non-encoding constructors removed):

   http://svn.apache.org/viewvc?view=rev&revision=609864

> FileWriter that accepts an encoding
> -----------------------------------
>
>                 Key: IO-153
>                 URL: https://issues.apache.org/jira/browse/IO-153
>             Project: Commons IO
>          Issue Type: New Feature
>          Components: Streams/Writers
>            Reporter: Stephen Colebourne
>            Priority: Minor
>             Fix For: 1.4
>
>         Attachments: FileWriterWithEncoding.java, io-FileWriterWithEncoding.patch
>
>
> Amazingly, even in JDK6 there are no constructors on FileWriter that accept an encoding.
> Attached is a patch to add FileWriterWithEncoding

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.