cancel
Showing results for 
Search instead for 
Did you mean: 

To upload a file from local machine to server

Former Member
0 Kudos

Hi,

I am working on sandbox i need to upload a CSV file residing on my local machine on to the sandbox server using java coding.

plz help me with the solution.

Regards

Savitha

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi savitha,

Try this code

try { // file writing

String mysheet = "My Sheet";

String mPath = "./temp/"; //(Absolute path)

String file_name ="filename";

File file = new File(mPath + file_name + ".csv");
BufferedWriter mOut = new BufferedWriter(new FileWriter(file));

mOut.write("\"H\",");

mOut.flush();

mOut.close(); //file writing ends
}catch(Exception e)
{

}

try { // file reading

FileInputStream mFileIn = new FileInputStream(file);

byte mBytes[] = new byte[mFileIn.available()];

mFileIn.read(mBytes, 0, mBytes.length);

mFileIn.close();

} catch (FileNotFoundException fileNotFoundException) {

throw new BusinessException(" Unable to find the CSV file");

}

Hope this helps you..

Regards,

Saleem

Former Member
0 Kudos

Hi,

The code that you sent is for creating a new file and writing the content in desired loaction.But for me the file which is already having the content has to be uploaded to the server.

Regards

Savitha

Former Member
0 Kudos

Hi Savitha

Please look into this links

Thanks

Tulasi

Former Member
0 Kudos

Hi Tulsi,

I am working on J2EE application using portal component with front end as jsp..so please provide any solution with regard to this..

Regards

Savitha

Former Member
0 Kudos

Hi Savitha

Sorry i dont have any idea on that...hope some replies from experts

Thanks

Tulasi