Sponsors: Michael Fertik - Best JAVA Web hosting Company & 30% off


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-07-2010, 09:24 AM
Member
 
Join Date: Jan 2010
Posts: 1
Rep Power: 0
d4dirty is on a distinguished road
Default 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:

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)
on this line:

Code:
ftpOut.write(buffer, 0, bytesRead);
of this function:

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);
			}
Is this my FTP server rejecting my upload? I just cant seem to figure out what the problem is.

Last edited by d4dirty; 01-07-2010 at 10:29 AM.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java Applet + File Uploading Moncleared New To Java 4 02-02-2009 06:33 PM
uploading a file itssiva Java Servlet 4 01-16-2009 10:41 AM
File Uploading aaliadhurue Advanced Java 4 01-16-2008 06:56 PM
Uploading image using JSP Java Tip Java Tips 0 01-11-2008 09:16 AM
Uploading files to FTP javaplus New To Java 0 12-19-2007 10:08 AM


Java Forums is supported by the best jsp hosting.

All times are GMT +2. The time now is 05:29 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org