Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Read a Big file Using Url.openStream  RSS feed

 
vinit kumar tyagi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am reading a file in an Applet from server using URL.openStream
I am getting file.available = 0
because my file is too big if file is small file.available gives me right value
my code is
URL url = LeftPane.getURL("logs/netstorm.log");
Log.debugLogClient(className, "Run", "", "", "URl "+ url.toString() );
file = url.openStream();
jt.setText("");
int available;
while( (available = file.read()) != -1)
{
available = file.available();
int bytes_to_read = available;
Log.debugLogClient(className, "Run", "", "", "bytes to Read "+ bytes_to_read);
byte bytes[] = new byte[available];
while ( false || bytes_to_read > 0 )
{
bytes_to_read -= file.read( bytes, ( available - bytes_to_read ), bytes_to_read );
}
jt.append(new String( bytes));
}
jt.setCaretPosition( jt.getText().length() );


i am writing a data in JTextArea

Please help me to sort the problem for handling large file.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think reading this wiki page will be helpful to you.
 
vinit kumar tyagi
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please Explian me how can i do that
can u give me some code
Please
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Umm... Explain how to read the wiki page?

After reading it, do you have a question about it? Because if it's not clear, then we should try to improve it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!