java - How to capture the file name from the server dynamically when some one uploads it -


below code read file server. want read & convert file dynamically (not hard coded )into different file format(csv). please guide me capture uploaded file name dynamically.

try     {          //creating file instance reference text file in java          string str1=null;         string str2=null;         string str3=null;         int cnt=0,len1=0,len2=0;           file text = new file("c:\\petty ascii detail.txt");          //creating scanner instnace read file in java          scanner scnr = new scanner(text);           file file = new file("c:\\test\\write1.txt");         //if file doesnt exists, create       if (!file.exists())        {         file.createnewfile();       }         //reading each line of file using scanner class         int linenumber = 1;        while(scnr.hasnextline())         {             string line = scnr.nextline();             cnt=line.length();               for(int i=0;i<3;i++)             {                  if (character.isdigit(line.charat(i)))                     str1=line;                 else                     str2=line;             }              len1=str1.length();             len2=str2.length();              if(len1!=len2)             {                 str3=str1+str2;                  filewriter fw = new filewriter(file.getabsolutefile(),true);                 bufferedwriter bw = new bufferedwriter(fw);                  bw.write(str3);                 bw.newline();                  system.out.println("done");                  bw.close();              }                  linenumber++;         }              }     catch (ioexception e)      {             e.printstacktrace();     } 

any suggestions appreciated.

thanks, balaji


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -