0

Hello any one tell me how do i create the program for upload to server.
plz any give some idea abt that

which commend is ur for uploading file to server in which way can i handle that

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by nitinmukesh
0

I myself is working on an applet which users can use to upload files to a ftp. The file can be loaded from local machine or it can be remote url.

You can try the below code.

//Add the file to read
File file = null;

//Add the file to write
File file1 = null;

FileInputStream fileinputstream = null;
BufferedInputStream bufferedinputstream = null;
FileOutputStream fileoutputstream = null;
BufferedOutputStream bufferedoutputstream = null;
try
{
    bufferedinputstream = new BufferedInputStream(fileinputstream = new FileInputStream(file));
    bufferedoutputstream = new BufferedOutputStream(fileoutputstream = new FileOutputStream(file1));
    byte abyte0[] = new byte[8192];
    int i;
    while((i = bufferedinputstream.read(abyte0)) != -1) 
	bufferedoutputstream.write(abyte0, 0, i);
}
finally
{
    try
    {
	bufferedinputstream.close();
    }
    catch(Exception exception1) { }
    try
    {
	fileinputstream.close();
    }
    catch(Exception exception2) { }
    try
    {
	bufferedoutputstream.close();
    }
    catch(Exception exception3) { }
    try
    {
	fileoutputstream.close();
    }
    catch(Exception exception4) { }
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.