Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.00 KB | None | 0 0
  1. //file: stringa nome file
  2. //car = carattere da sostituire allo spazio
  3.  
  4.                 fileCorr = new File(file);
  5.                String ristemp="";
  6.                char temp;
  7.                int carInt, count=0;
  8.                if (fileCorr.exists())
  9.                {
  10.                     BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
  11.                     while ((carInt=in.read())!=-1)
  12.                     {
  13.                         temp = (char) carInt;
  14.                         if( temp == ' ')
  15.                         {
  16.                             ristemp=car+"";
  17.                             count++;
  18.                         }
  19.                         else
  20.                         {
  21.                             ristemp=temp+"";
  22.                         }
  23.                            
  24.                     }
  25.                     in.close();
  26.                      if(count>0)
  27.                     {
  28.                         BufferedWriter dest = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file)));
  29.                         dest.write(ristemp);   
  30.                         dest.close();
  31.                     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement