• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.io.InputStreamReader error

 
Sundar Venkat
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an applet which read a file from the server & displays. I am trying to read the length of the file, so that i can display only a part of the file from the end. But I am getting an error as
LfApplet:cannot resolve symbol
symbol:method.length()
location: class java.io.InputStreamReader
nbytes=tempInputStream.length();
here is my code
public void getLog( )

{
String queryBase= getParameter("querybase");
URL tempURL ; //the URL to be loaded
InputStreamReader tempInputStream ; //stream from which to read data
int nread,nbytes = 0 ;
char[] data = new char[100] ;
StringWriter aString = new StringWriter() ;
try {
tempURL = new URL(queryBase);
try {
tempInputStream = new InputStreamReader(tempURL.openStream());
try {
nbytes=tempInputStream.length();
while( (nread = tempInputStream.read(data,nbytes-200,200)) > 0){
aString.write(data,0,nread) ;
}
}
catch(IOException copyEx) {
System.err.println("copyEx: " + copyEx);
}
larea.append(aString.toString()+"\n") ;
} .
catch (IOException retrieveEx) {
System.err.println("retrievEx: " + retrieveEx);
}
}
catch (MalformedURLException murlEx) {
System.err.println("new URL threw ex: " + murlEx);
}
Can anyone suggets or show me some pseudo code that reads last few bytes from a file & displays
 
Tim Holloway
Saloon Keeper
Posts: 18359
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
... And again. A WEB SERVER IS NOT A FILE SERVER!
You can write a servlet that does that, but all a client - applet or HTML form - can do is say "Please write bytes XXXX to YYYY back to me". Then the servlet must open the file, seek to position XXXX, copy to the output stream until it reaches YYYY, and then close the input file. A web client cannot demand, it may only request.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic