j2se 1.5 broke this code snippet - anyone ???

Discussion in 'Java' started by Gil Blais, Jul 12, 2004.

  1. Gil Blais

    Gil Blais Guest

    public class PrintFileCreator extends java.io.PrintStream implements
    INTERFACES.IF {
    public PrintFileCreator(String filename, boolean append) throws
    java.lang.Exception {
    super(
    new java.io.BufferedOutputStream(
    new java.io.FileOutputStream(filename,append)));
    }
    }
     
    Gil Blais, Jul 12, 2004
    #1
    1. Advertising

  2. On Mon, 12 Jul 2004 08:23:54 GMT, Gil Blais wrote:

    > public class PrintFileCreator extends java.io.PrintStream implements


    You could help yourself various ways.

    1) Provide a self-contained example as
    opposed to a snippet..
    <http://www.physci.org/codes/sscce.jsp>

    2) State what the message was..
    <http://www.physci.org/codes/javafaq.jsp#exact>

    3) Do not start posts claiming the API is broke,
    even if you are sure it is. It makes you look
    like a noob.

    HTH

    --
    Andrew Thompson
    http://www.PhySci.org/ Open-source software suite
    http://www.PhySci.org/codes/ Web & IT Help
    http://www.1point1C.org/ Science & Technology
     
    Andrew Thompson, Jul 12, 2004
    #2
    1. Advertising

  3. Gil Blais

    Gil Blais Guest

    This is the message that I get:
    The return type is incompatible with Appendable.append(CharSequence),
    PrintStream.append(CharSequence)

    "Gil Blais" <> wrote in message
    news:uUrIc.35758$...
    > public class PrintFileCreator extends java.io.PrintStream implements
    > INTERFACES.IF {
    > public PrintFileCreator(String filename, boolean append) throws
    > java.lang.Exception {
    > super(
    > new java.io.BufferedOutputStream(
    > new java.io.FileOutputStream(filename,append)));
    > }
    > }
    >
    >
    >
     
    Gil Blais, Jul 12, 2004
    #3
  4. Gil Blais

    Chris Smith Guest

    Gil Blais wrote:
    > This is the message that I get:
    > The return type is incompatible with Appendable.append(CharSequence),
    > PrintStream.append(CharSequence)


    Then the error isn't about the code you posted, since there are no
    return types in that code.

    --
    www.designacourse.com
    The Easiest Way to Train Anyone... Anywhere.

    Chris Smith - Lead Software Developer/Technical Trainer
    MindIQ Corporation
     
    Chris Smith, Jul 12, 2004
    #4
  5. Gil Blais

    Roedy Green Guest

    On Mon, 12 Jul 2004 08:23:54 GMT, "Gil Blais" <>
    wrote or quoted :

    >public class PrintFileCreator extends java.io.PrintStream implements
    >INTERFACES.IF {


    is this a matter of PrintStream being deprecated?

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    Roedy Green, Jul 12, 2004
    #5
  6. Gil Blais

    Doug Pardee Guest

    "Gil Blais" <> wrote:
    > This is the message that I get:
    > The return type is incompatible with Appendable.append(CharSequence),
    > PrintStream.append(CharSequence)
    >
    > > public class PrintFileCreator extends java.io.PrintStream implements
    > > INTERFACES.IF {
    > > public PrintFileCreator(String filename, boolean append) throws


    java.io.PrintStream (which your class extends) now has a couple of
    methods called "append". You need to change your formal parameter name
    (boolean append) to something else.
     
    Doug Pardee, Jul 12, 2004
    #6
  7. Gil Blais

    Roedy Green Guest

    On 12 Jul 2004 14:22:48 -0700, (Doug Pardee)
    wrote or quoted :

    >
    >java.io.PrintStream (which your class extends) now has a couple of
    >methods called "append". You need to change your formal parameter name
    >(boolean append) to something else.


    Java has no problem with having a parameter and method with the same
    name. It might not be a great idea, but it should not cause a syntax
    error.

    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    Roedy Green, Jul 12, 2004
    #7
  8. Gil Blais

    xarax Guest

    "Roedy Green" <> wrote in message
    news:...
    > On 12 Jul 2004 14:22:48 -0700, (Doug Pardee)
    > wrote or quoted :
    >
    > >
    > >java.io.PrintStream (which your class extends) now has a couple of
    > >methods called "append". You need to change your formal parameter name
    > >(boolean append) to something else.

    >
    > Java has no problem with having a parameter and method with the same
    > name. It might not be a great idea, but it should not cause a syntax
    > error.


    I think you're right, but try changing the parameter
    name to see if the syntax error goes away. If it resolves
    the syntax error, then you have likely found a compiler bug
    or maybe the JLS must be perused (maybe the new compiler
    is more compliant with the JLS).
     
    xarax, Jul 13, 2004
    #8
  9. Gil Blais

    Gil Blais Guest

    I changed the parameter name to appendToFile and the error persists. All I
    am trying to accomplish is to generate a mechanism to be able to do the
    following:
    PrintFile Newout = new PrintFile(filepath,true);
    Newout.println("# Append request follows...");
    Newout.println(whatToAppend);
    Newout.close();

    "Roedy Green" <> wrote in message
    news:...
    > On Mon, 12 Jul 2004 08:23:54 GMT, "Gil Blais" <>
    > wrote or quoted :
    >
    > >public class PrintFileCreator extends java.io.PrintStream implements
    > >INTERFACES.IF {

    >
    > is this a matter of PrintStream being deprecated?
    >
    > --
    > Canadian Mind Products, Roedy Green.
    > Coaching, problem solving, economical contract programming.
    > See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    >
     
    Gil Blais, Jul 13, 2004
    #9
  10. Gil Blais wrote:

    > This is the message that I get:
    > The return type is incompatible with Appendable.append(CharSequence),
    > PrintStream.append(CharSequence)


    How about cutting and pasting the actual compiler message, which will
    come with a pointer to the exact context of the error. It appears that
    the message you gave is complaining that your class has overridden
    PrintStream.append(CharSequence) (part of PrintStream's implementation
    of Appendable) with a method that returns an incompatible type. There
    is nothing remotely like that in the code snippet you provided, so
    either you have discovered a compiler bug or you have not provided the
    relevant code.


    John Bollinger
     
    John C. Bollinger, Jul 13, 2004
    #10
  11. Gil Blais

    Hemal Pandya Guest

    "Gil Blais" <> writes:

    > This is the message that I get:
    > The return type is incompatible with Appendable.append(CharSequence),
    > PrintStream.append(CharSequence)
    >
    > "Gil Blais" <> wrote in message
    > news:uUrIc.35758$...
    >> public class PrintFileCreator extends java.io.PrintStream implements
    >> INTERFACES.IF {
    >> public PrintFileCreator(String filename, boolean append) throws
    >> java.lang.Exception {
    >> super(
    >> new java.io.BufferedOutputStream(
    >> new java.io.FileOutputStream(filename,append)));
    >> }
    >> }
    >>
    >>


    What is INTERFACES? What is Appendable? I am able to compile without
    error if I comment out the "implements" part.

    I suspect INTERFACES.IF is an Appendable, Appendable has method
    append(CharSequence) and its return type is incompatible with the new
    append(CharSequence) method of PrintStream.
     
    Hemal Pandya, Jul 15, 2004
    #11
  12. Gil Blais

    Gil Blais Guest

    Thank you Hemal - that did the trick. Makes me feel quite foolish as I
    should have noticed it, but...
    Gil Blais


    "Hemal Pandya" <> wrote in message
    news:...
    > "Gil Blais" <> writes:
    >
    > > This is the message that I get:
    > > The return type is incompatible with Appendable.append(CharSequence),
    > > PrintStream.append(CharSequence)
    > >
    > > "Gil Blais" <> wrote in message
    > > news:uUrIc.35758$...
    > >> public class PrintFileCreator extends java.io.PrintStream implements
    > >> INTERFACES.IF {
    > >> public PrintFileCreator(String filename, boolean append) throws
    > >> java.lang.Exception {
    > >> super(
    > >> new java.io.BufferedOutputStream(
    > >> new java.io.FileOutputStream(filename,append)));
    > >> }
    > >> }
    > >>
    > >>

    >
    > What is INTERFACES? What is Appendable? I am able to compile without
    > error if I comment out the "implements" part.
    >
    > I suspect INTERFACES.IF is an Appendable, Appendable has method
    > append(CharSequence) and its return type is incompatible with the new
    > append(CharSequence) method of PrintStream.
    >
     
    Gil Blais, Jul 15, 2004
    #12
  13. Gil Blais

    Hemal Pandya Guest

    "Gil Blais" <> writes:

    > Thank you Hemal - that did the trick. Makes me feel quite foolish as I
    > should have noticed it, but...
    > Gil Blais


    You are welcome Gil. I just forced an extra build with a foolish
    mistake, if that is any relief.

    [...]
     
    Hemal Pandya, Jul 15, 2004
    #13
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Martijn Mulder

    J2SE 1.4.2 or J2SE 5.0?

    Martijn Mulder, Jun 27, 2005, in forum: Java
    Replies:
    15
    Views:
    1,884
    Tor Iver Wilhelmsen
    Jun 28, 2005
  2. Manfred Schneider
    Replies:
    6
    Views:
    3,242
    Manfred Schneider
    Dec 17, 2005
  3. David N. Welton
    Replies:
    10
    Views:
    761
    Thomas Weidenfeller
    Feb 9, 2006
  4. Replies:
    0
    Views:
    551
  5. Replies:
    5
    Views:
    109
    apatheticagnostic
    May 8, 2008
Loading...

Share This Page