j2se 1.5 broke this code snippet - anyone ???

G

Gil Blais

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)));
}
}
 
G

Gil Blais

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

Chris Smith

Gil said:
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
 
D

Doug Pardee

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

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.
 
R

Roedy Green

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.
 
X

xarax

Roedy Green said:
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).
 
G

Gil Blais

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();
 
J

John C. Bollinger

Gil said:
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
(e-mail address removed)
 
H

Hemal Pandya

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

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.
 
G

Gil Blais

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

Hemal Pandya

Gil Blais said:
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.

[...]
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,689
Members
48,796
Latest member
Greg L.

Latest Threads

Top