I want to take some information from a document inside the project text_d.txt.
Now I send "text_d.txt" through a string s2.The file already exists(text_d.txt) but the output file s3,doesn't show anything(empty). The question is: Why it doesn't show anything. Did I write anything wrong?
dict.txt
da yesprofesor teacher
invata learns
java java
zece ten
programare programming
noteaza rates
primeste gets
student student
and text_d.txt
Student invata programare java. Profesor noteaza student. Nero primeste zece.
This method is used by the file-writing code:
   public String getTtoD(String _wordtotranslate,String s)throws Throwable
    {
      FileInputStream _dict=new FileInputStream(s);
      BufferedReader _read=new BufferedReader(new InputStreamReader(_dict));
      String _line=_read.readLine();
      char c;
      int sem=0;
      for(int i=0;i<_wordtotranslate.length();i++)
      {
          c=_wordtotranslate.charAt(i);
          if(c>='A' && c<='Z')
              sem=1;
      }
      _wordtotranslate=_wordtotranslate.toLowerCase();
      while(_line!=null)
      {
         String [] _v=_line.split(" ");
         if(_wordtotranslate.equals(_v[1]))
         {
             if(sem==1)
                  {_v[0]=_v[0].substring(0,1).toUpperCase()+_v[0].substring(1);
                  return _v[0];
                  }
             return _v[0];
         }
         _line=_read.readLine();
      }
     _read.close();
     if(sem==1)return             _wordtotranslate=_wordtotranslate.substring(0,1).toUpperCase()+_wordtotranslate.substring(1);
     return _wordtotranslate;
    }
This is the code where the file is written:
       if(dan==1)
     {
      File f=new File(s3);
      f.createNewFile();
      FileInputStream _inputfile=new FileInputStream(s2);
      BufferedReader _readfile=new BufferedReader(new InputStreamReader(_inputfile));
      String _str=_readfile.readLine();
      FileWriter _filewrite=new FileWriter(f);
      BufferedWriter _buffwrt=new BufferedWriter(_filewrite);
      while(_str!=null)
      {
            while (_str != null) {
                String[] _vect = _str.split(" ");
                if(_vect.length>4)throw new WrongSyntax();
                int i;
                for (i = 0; i < _vect.length; i++) {
                    if (_vect[i].contains(".")) {
                         _vect[i]=removeCharAt(_vect[i],_vect[i].indexOf("."));
                        _buffwrt.write(getDtoT(_vect[i],s4) + ".");
                    }
                    else
                        _buffwrt.write(getDtoT(_vect[i],s4) + " ");
                    _buffwrt.flush();
                }
                _buffwrt.flush();
                _str =_readfile.readLine();
            }
            _buffwrt.close();
      }
 
    