Results 1 to 1 of 1
Thread: Uploading in an ftp applet help
- 01-07-2010, 09:24 AM #1
Member
- Join Date
- Jan 2010
- Posts
- 1
- Rep Power
- 0
Uploading in an ftp applet help
Hi Guys,
I am fairly new to applets, and at my wits end on this one. I am writing a simple ftp file upload applet. I have been able to connect to my FTP server, but after sending 8 KB's of data of a file over I constantly get a:
on this line:Java Code:java.lang.NullPointerException at java.io.BufferedOutputStream.flushBuffer(Unknown Source) at java.io.BufferedOutputStream.write(Unknown Source) at Uploader.run(Uploader.java:267) at java.lang.Thread.run(Unknown Source)
of this function:Java Code:ftpOut.write(buffer, 0, bytesRead);
Is this my FTP server rejecting my upload? I just cant seem to figure out what the problem is.Java Code:BufferedOutputStream ftpOut = new BufferedOutputStream(client.storeFileStream(this.uploadedFileName)); BufferedInputStream fileIn = new BufferedInputStream(new FileInputStream(this.theFile)); // initalise some working vars byte[] buffer = new byte[1024]; int bytesRead = fileIn.read(buffer); long runningTotal = 0; long total = this.theFile.length(); int percentComplete = 0; // do the upload loop System.out.println("Starting upload Loop"); while (bytesRead > 0) { System.out.println("Upload Looped writing" + percentComplete); // write the buffer ftpOut.write(buffer, 0, bytesRead); // update the totals runningTotal += bytesRead; percentComplete = (int)((double)runningTotal / (double)total * 100); this.txtFileName.setText("Uploaded " + getHumanReadibleFileSize(runningTotal) + " (" + percentComplete + "%)"); System.out.println("Upload Looped reading" + percentComplete); // read some more from the input bytesRead = fileIn.read(buffer); }Last edited by d4dirty; 01-07-2010 at 10:29 AM.
Similar Threads
-
Java Applet + File Uploading
By Moncleared in forum New To JavaReplies: 4Last Post: 02-02-2009, 06:33 PM -
uploading a file
By itssiva in forum Java ServletReplies: 4Last Post: 01-16-2009, 10:41 AM -
File Uploading
By aaliadhurue in forum Advanced JavaReplies: 4Last Post: 01-16-2008, 06:56 PM -
Uploading image using JSP
By Java Tip in forum Java TipReplies: 0Last Post: 01-11-2008, 09:16 AM -
Uploading files to FTP
By javaplus in forum New To JavaReplies: 0Last Post: 12-19-2007, 10:08 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks