• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Drowning need someone to throw me a line.

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am posting a file from an applet to a servlet, problem is it is slow, the file unwantedly cached in memory before transmitting and I don't know how to get the ammount of data that has been sent(It seems that flushing the buffer and counting what you put in it is utterly useless; note I'm using this to draw my progress bar). I need some help here because this project is in danger.
-a man in need
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would need a few more details to completely figure this out but, it would seem that you aren't using the correct InputStreams to do this. Can you post the code where you read the file in and write it to the URLConnection?
 
Declan Conlon
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
class FileBG extends Thread
{
public ProgressBar pgbar;
private BarBG barthread;
private DataInputStream datain;
private DataOutputStream dataout;;
private long filesize;
private ByteThread bytethread;
public void run()
{
try
{
long byteswritten = 0;
float percentup = 0;
byte[] outarray = new byte[2048];
while (true)
{
datain.read(outarray);
dataout.write(outarray);
dataout.flush();
}
close and catch here
Hope you can help me now.
 
Declan Conlon
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry forgot the URLConnection setup
File outfile = new File(globalfilestr);
URL location = new URL(getCodeBase(), "http://127.0.0.1:8080/examples/servlet/ServerServ");
URLConnection out = location.openConnection();
out.setUseCaches(false);
out.setRequestProperty("Content-Type", "application/x-java-serialized-object");
out.setRequestProperty("Filename", globalfilename);
DataInputStream datain = new DataInputStream(filein);
DataOutputStream dataout = new DataOutputStream(out.getOutputStream());
filethread.setFileSize(outfile.length());
filethread.setInputStream(datain);
filethread.setOutputStream(dataout);
filethread.setPgBar(pgbar);
filethread.start();
reply
    Bookmark Topic Watch Topic
  • New Topic