spring - read data from MultipartFile which has csv uploaded from browser -
may doing worng using multipartfile upload feature.
i have read data csv file chosen client through browser. used multipartfile upload file. file coming controller unable read csv data it. please guide best way or me read csv data multipartfile. jsp has
<form method="post" action="uploadfile" enctype="multipart/form-data"> file upload: <input type="file" name="file"> <input type="submit" value="upload"> press here upload file! </form>
the controller has
@requestmapping(value = "/uploadfile", method = requestmethod.post) public string uploadfilehandler(@requestparam("file") multipartfile file) {
thanks.
i figured out workaround. converted file bytes , converted bytes string. string applied string.split() wanted out of file.
@requestmapping(value = "/uploadfile", method = requestmethod.post) public string uploadfilehandler(@requestparam("file") multipartfile file) { if (!file.isempty()) { try { byte[] bytes = file.getbytes(); string completedata = new string(bytes); string[] rows = completedata.split("#"); string[] columns = rows[0].split(",");
Comments
Post a Comment