• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

java.io.InputStreamReader error

 
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
 
Bartender
Posts: 20849
125
Android Eclipse IDE Tomcat Server Redhat Java 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.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!