Is this really Cause of using FTP code of java?
<p>I got the data from the mainframe application. That file is the name of 'sample.txt' file. When i read the data using the java code through the 'FTP' to store it the data to oracle database. It shows some special characters in the name field. Additionly one information our product we are using the internationalization also . We use the portuguese, spanish,english. I run this using the standalone java program.</p>

<p>For Example the given input, </p>

<pre><code>DTALRVAQCRAÜL TORRENTS  +34 93 8640317  +34 93 8640304   RAUL.TORRENS@TRW.COM 20100511FAO
DTALRVAQCRAÜL TORRENTS  +34 93 8640317  +34 93 8640304   RAUL.TORRENS@TRW.COM 20100511FAO
</code></pre>

<p>output is ,</p>

<pre><code>DTALRVAQCRAðL TORRENTS  +34 93 8640317  +34 93 8640304   RAUL.TORRENS@TRW.COM 20100511FAO
DTALRVAQCRAðL TORRENTS  +34 93 8640317  +34 93 8640304   RAUL.TORRENS@TRW.COM 20100511FAO
</code></pre>

<p>What is the solution for me to overcome this issue.</p>

<p>My sample java file is ,</p>

<pre><code>public void loadData() throws Exception {

          emailMsg.setLength(0);           
          BufferedReader br = null;       
          int r12InsCnt = 0; 
          int r12UpdCnt = 0;
          String strLine = null;          
          int totalrows = 0; int trailerCnt = 0;
          String rundate = "";
          String endDate = "";
          Connection conn = null;        
          CallableStatement cs = null;
          String tmpFilename="";
          List regns = new ArrayList();
          BufferedOutputStream bos = null;
          int buffer = 0;
          InputStream in;
          FileInputStream fstream1=null;
          File tempFile = null;

          String METHOD_NAME = "loadData";            
          try
          {                           
              String DATE_FORMAT = "MMddyyyy";
              java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DATE_FORMAT);
              Calendar c1 = Calendar.getInstance();
              String today = sdf.format(c1.getTime()); //mmddyyyy

              CommonUtil cu = new CommonUtil();
              rundate = cu.getCurrentDtTimestamp("yyyy/MM/dd HH:mm:ss.S");            

              //get NAS server details from DynoProp table
              PropertyManager propmanager = PropertyManager.getInstance();            
              PropertyGroup vrpgProGroup = propmanager.getGroup("ServerCredentials");       
              String user = vrpgProGroup.getString("id");             
              String password = vrpgProGroup.getString("password"); 
              String serverName = vrpgProGroup.getString("server");

              FtpClientAttributes ftpAttribs = new FtpClientAttributes.Builder(serverName,user,password).build();
              FtpProxyClient ftp = new FtpProxyClient(ftpAttribs);                  
              //ftp.setBinaryMode();
              ftp.setAsciiMode();
              ftp.changeDirectory("Vrpg");

              if(ftp.isFileExists("vrpg.contacts.txt"))
              {
                     tmpFilename = "vrpg_contacts_Pr_" + today + ".txt";
                     ftp.renameFile("vrpg.contacts.txt", tmpFilename);
                     in = ftp.getFile(tmpFilename);

                     //String tempDir = "/proj/mingle/was/install/mingle_mingleEAR.ear/mingleWeb.war/vrpg/";
                     String tempDir = System.getProperty("java.io.tmpdir") + "/";                    

                     if("DESKTOP".equalsIgnoreCase(System.getProperty("DEPLOYED_ENVIRONMENT"))) {
                         tempDir = "C:/SDPRNG/vrpg/"; 
                     }

                     bos = new BufferedOutputStream(new FileOutputStream(tempDir + tmpFilename));                                        
                      while ((buffer = in.read()) != -1) {
                          bos.write(buffer);
                      }
                      bos.flush();
                      bos.close();                    
                      ftp.cleanup();

                      tempFile = new File(tempDir + tmpFilename);
                      fstream1 = new FileInputStream(tempFile);
                      br = new BufferedReader(new InputStreamReader(fstream1,"CP1252"));

                      conn = DBConnection.getmingleConnection();
                      PreparedStatement pstmt = null;

                        try{
                            if(conn!=null){
                            pstmt = conn.prepareStatement(mingleQuery.UPDATER12DELETEFLAG);
                            pstmt.execute();
                            }
                        }catch(SQLException e){
                            throw new mingleBusinessException(
                                    new ruralExceptionAttributes.Builder(
                                    CLASS_NAME, METHOD_NAME).build(),
                                    "Getting exception while updating the delete flag in loadData ", e);
                        }

                      while ((strLine = br.readLine()) != null)                       
                      { 
                          try
                          {
                               //Header:"AA", Trailer:"ZZ", Detail:"DT" record.
                               if(strLine.substring(0,2).equalsIgnoreCase("ZZ"))
                               { trailerCnt = Integer.parseInt(strLine.substring(36,43)); }

                               if(strLine.substring(0,2).equalsIgnoreCase("DT"))
                               {                  
                                  totalrows++;
                                  System.out.println("The Values is :"+strLine.length());
                                  //System.out.println("calling SP for:" + strLine.substring(2,7));
                                  //insert to R12
                                   try
                                   {                   
                                     cs = null;
                                     cs = conn.prepareCall("{call createDetailContactRawdata(?,?,?,?,?,?,?,?,?,?,?,?)}");                      
                                     cs.setString(1, strLine.substring(2,7).trim());  //sitecode
                                     cs.setString(2, "vrpg");
                                     cs.setString(3, strLine.substring(7,9).trim()); //title                     
                                     cs.setString(4, strLine.substring(160).trim()); //org
                                     cs.setString(5, strLine.substring(9,41).trim()); //name
                                     cs.setString(6, strLine.substring(41,63).trim()); //phone
                                     cs.setString(7, strLine.substring(63,85).trim()); //cell
                                     cs.setString(8, strLine.substring(85,107).trim()); //fax
                                     cs.setString(9, strLine.substring(107,152).trim()); //email
                                     cs.setString(10, strLine.substring(152,160));      //last update date                  
                                     cs.registerOutParameter(11, java.sql.Types.VARCHAR);
                                     cs.registerOutParameter(12, java.sql.Types.CHAR);
                                     cs.execute();                          
                                     if(!"S".equals(cs.getString(11))){
                                        emailMsg.append(cs.getString(11));                                          
                                     } 
                                     else 
                                     { 
                                        if(cs.getString(12).equalsIgnoreCase("I")) r12InsCnt++;
                                        if(cs.getString(12).equalsIgnoreCase("U")) r12UpdCnt++;
                                     }
                                     cs.close();                                                    
                                   } catch(Exception e) {
                                     System.out.println("sp error:" + e.getMessage());  
                                     emailMsg.append("Error occured executing SP:" + strLine.substring(2,7)+strLine.substring(7,9).trim()+ strLine.substring(160).trim()+ e.getMessage() + "\n");
                                   }
                               }//end if DT

                          }catch(Exception e){
                             System.out.println("error inside while" + e.getMessage()); 
                             emailMsg.append("Error reading vrpg contacts file:" +  strLine.substring(0,25)+ e.getMessage()+ "\n");
                             log.logp(Level.INFO,CLASS_NAME,"loadData", "error reading vrpg contacts file" + e.getMessage().toString()); 
                          }

                      } //end while

                      try{
                            if(conn!=null){
                            pstmt = conn.prepareStatement(mingleQuery.DELETER12_DELETEFLAG_Y);
                            pstmt.execute();
                            }
                        }catch(SQLException e){
                            throw new mingleBusinessException(
                                    new ruralExceptionAttributes.Builder(
                                    CLASS_NAME, METHOD_NAME).build(),
                                    "Getting exception while deleting the records with delete flag 'Y' in loadData ", e);
                        }

                      br.close();
                      conn.close();
                      if(pstmt != null) pstmt.close();

                      //System.out.println("Total Rows ** :" + totalrows); 
                      //System.out.println("Trailer Count** :" + trailerCnt); 

                      if(totalrows &lt; trailerCnt) { emailMsg.append("Total rows processed is less than trailer record count:" + totalrows + "/" + trailerCnt + "\n"); }

                     /*System.out.println("r12InsCnt:" + r12InsCnt);                 
                      System.out.println("r12UpdCnt:" + r12UpdCnt);*/

                     endDate = cu.getCurrentDtTimestamp("MM/dd/yyyy HH:mm:ss");
                     //create log for batch process with number of rows retrieved from vrpg and rows inserted into mingle
                     BatchLogBO batchLogBO = new BatchLogBO();
                     batchLogBO.setBusnType(busnType);          
                     batchLogBO.setRatingRegion(region);            
                     batchLogBO.setStartDate(rundate);
                     batchLogBO.setEndDate(endDate);
                     batchLogBO.setRowsReceived(totalrows);
                     batchLogBO.setRowsInserted(r12InsCnt);
                     batchLogBO.setRowsUpdated(r12UpdCnt);
                     batchLogBO.setRowsDeleted(0);
                     batchLogBO.setBatchName("vrpgCONATCTS");
                     batchLogBO.setBatchType("DAILY");
                     batchLogBO.setvrpgCode("NONE");
                     batchLogBO.setLastUpdtPgmCode("BATCH");
                     try
                     { 
                          mingle_BINDING_AS.beginTransaction();
                          batchLogBO = mingle_BINDING_AS.bindCreateOrUpdate(batchLogBO);
                          mingle_BINDING_AS.commitTransaction();
                     } catch(Exception e) {
                          emailMsg.append("Error inserting batchLog:" + e.getMessage() + "\n");
                     }                                      
                     //System.out.println("about to run load instance for all regions");
                     try
                     {
                         //call loadInstance method to load instance data for each region                    
                         regns = getRegions();
                         for(int k=0; k&lt;regns.size(); k++) {                         
                           loadInstance(cu.getCurrentDtTimestamp("MM/dd/yyyy"),regns.get(k).toString());
                         }
                     }catch(Exception e) {
                        emailMsg.append("Error getting regions to run loadInstance:" + e.getMessage() + "\n"); 
                     }

                 } else {                  
                   Mailbox.sendMail("rpgsupp@rural.com", "rpgsupp@rural.com", System.getProperty("DEPLOYED_ENVIRONMENT"), "vrpg Contacts file not found on NAS");
                   return;
                 }

                 if ( (emailMsg.toString().length() &gt; 1) &amp;&amp; (!emailMsg.toString().equalsIgnoreCase(null)) &amp;&amp; (!emailMsg.toString().equalsIgnoreCase("null")) ) {     
                     Mailbox.sendMail("rpgsupp@rural.com", "rpgsupp@rural.com", System.getProperty("DEPLOYED_ENVIRONMENT")+ ":Load vrpg Contacts Details",  emailMsg.toString());
                 }

                 tempFile.delete(); //delete tmp file from app server

                 ftp = new FtpProxyClient(ftpAttribs);
                 emailMsg.append(cu.deletefile(ftp,today,"vrpg_Contacts_")); //delete old files from NAS
                 ftp.cleanup();

            } catch(Exception e) {
                System.out.println("inside final exception:" + e.getMessage());
                if(br != null) br.close();              
                if(conn !=null) conn.close();
                emailMsg.append("Error:" + e.getMessage()+ "\n");
                Mailbox.sendMail("rpgsupp@rural.com", "rpgsupp@rural.com", System.getProperty("DEPLOYED_ENVIRONMENT")+ ":Load vrpg Contacts Details",  emailMsg.toString());
                log.logp(Level.INFO,CLASS_NAME,"loadData", "error getting vrpg contacts file from NAS:" + e.getMessage().toString());
            }

    }
</code></pre>
