This week's book giveaway is in the HTML/CSS/JavaScript forum.
We're giving away four copies of Practical SVG and have Chris Coyier on-line!
See this thread for details.
Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

new InputStreamReader(InputStream is) Please help me understand

 
Madhu Madala
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.io.*;
public class Io{
public static void main(String args[]){
FileReader fr= new FileReader("c:/Io.java");
InputStreamReader = new InputStreamReader(fr);//Line 1
LineNumberInputStream = new LineNumberInputStream(fr); Line 2
}
}

BOTH InputStreamReader and LineNumberInputStream has same type of constructor which takes InputStream type.
BUT Line 1 doesnt compile
Line 2 compiles.
 
Madhu Madala
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi My question is Why does Line one doesnt compile.
Thanks in Advance
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're missing variable names in line 1 and line 2. (Like 'fr' in the previous line).
Also, you're going to have a hard time doing anything useful with two different streams/readers attached to the same inner stream. The InputStreamReader and the LineNumberInputStream are both competing for bytes from the same source - each byte will be read by one of the other, but not both. Very confusing. You probably want to attach everything serially:
A a = new A();
B b = new B(a);
C c = new C(b);
D d = new D(c);
rather than
A a = new A();
B b = new B(a);
C c = new C(b);
D d = new D(a);
For your situation, this probably means using a LineNumberReader rather than a LineNumberInputStream.
 
Madhu Madala
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You were right I am sorry i wanted to mention LineNumberReader lnr=new LineNumberReader(fr);
Thank you
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!