Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8174789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:33:14+00:00 2026-06-06T22:33:14+00:00

I got the data from the mainframe application. That file is the name of

  • 0

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.

For Example the given input,

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

output is ,

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

What is the solution for me to overcome this issue.

My sample java file is ,

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 < 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<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() > 1) && (!emailMsg.toString().equalsIgnoreCase(null)) && (!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());
            }

    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T22:33:15+00:00Added an answer on June 6, 2026 at 10:33 pm

    Here’s your problem, most likely:

    br = new BufferedReader(new InputStreamReader(fstream1,"CP1252"));
    

    You’re converting the bytes of the file into characters by assuming that they’re using the CP1252 encoding.

    If the actual encoding of the file is not CP1252, then the bytes will map into the wrong characters. (Just about every encoding uses the same values for “ASCII characters”, so you’d only see the error on “special” characters.) What made you decide to use CP1252 for decoding, and are you sure this is correct?

    To resolve your problem, find out the actual encoding used by these files, and pass that into the InputStreamReader constructor instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got an application that downloads data from a 3rd party at 3am every
I've got a perl script that loads data from an Excel XLS file into
I got a treeview data loaded from a XML file. I want to perform
We've got a number of gridviews that we're populating with data from an ADABAS
I've currently got a query that selects metrics data from two tables whilst getting
I have a maintenance application that has to turn enterprise data (from various databases/tables)
I got json data from the server by ajax: request.responseText=[{name:xxx},{name:xxx},{name:xx}]. Then I use the
I got this data from my server using JSON: { ID = 198; dtDate
In one of our apps, we read in data from a file and expand
I was created one small business application..Here I got the data from server and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.