Java writes a file to a custom folder
File file = new File ("E: // rawSpeechRecordData //"); File newFile = null; if (! File. exists () {file. mkdir (); if (file. isDirectory () {SimpleDateFormat format = new SimpleDateFormat ("yyyyMMddHHmmss"); String date = format. format (new Date (System. currentTimeMillis (); newFile = new File ("E: // rawSpeechRecordData //" + fileNametemp + date + ". pcm "); item. write (newFile); // store data to the database System. out. println ("***********************" + newFile. getPath (); mFileInfoDao. addFilePathInfos (newFile. getPath (), FileNametemp); printWriter. write ("data submitted successfully! "); System. out. println (file); System. out. println ("Content-Disposition: form-data; name = \" file \ "; filename = \" "); System. out. println ("**********************");} else {if (file. isDirectory () {SimpleDateFormat format = new SimpleDateFormat ("yyyyMMddHHmmss"); String date = format. format (new Date (System. currentTimeMillis (); newFile = new File ("E: // rawSpeechRecordData //" + fileNametemp + date + ". pcm "); item. wr Ite (newFile); // data is stored in the database mFileInfoDao. addFilePathInfos (newFile. getPath (), fileNametemp); printWriter. write ("data submitted successfully! "); System. out. println ("***********************" + newFile. getPath (); System. out. println (file); System. out. println ("Content-Disposition: form-data; name = \" file \ "; filename = \" "); System. out. println ("**********************"); }}} catch (FileUploadException e) {// TODO Auto-generated catch blocke. printStackTrace (); System. out. print (e. toString ();} catch (Exception e) {// TODO Auto-generated catch blocke. printStackTrace ();}}