Thales' cellular IoT products business is now part of Telit Cinterion, find out more.

You are here

How can I customize java.io.IOException? | Telit Cinterion IoT Developer Community

November 6, 2014 - 12:47am, 2534 views

Hello,

I am working with TC65.My application performs certain calculations. In order to do the final calculation the application request a data from a Servlet using http post request.
I have a method to create a backup file in memory flash in order to copy the servlet data to read it then if there is a GSM problem connection.
 If I disconnect the antenna of the modem or there is a problem with the GMS network I receive an exception error instead of the expected data from the backup file.
What is your suggestion?.Should I need to customize the error exception to run the method I have to read the data from the backup file? How Can I do it?
I have a method readFromFile() in order to return the value if there is a problem with the network but I can't avoid the exception error.

Regards,





 public int processServerResponse(HttpConnection http,InputStream iStream)
   throws IOException{
  
     
   try {
               
         }catch ( Exception ex ){
            System.out.println( "Http : ex : " + ex.getClass() + " : " + ex.getMessage() );
            ex.printStackTrace();
        }
       
        return result;
      
   } 
  
                   }



//receiving data from Servlet in order to do the final calculation
           try {
                       post.enviarPost();
                       Thread.sleep(100);
                     
                   } catch (IOException ex) {
                       ex.printStackTrace();
                   } catch (InterruptedException ex) {
            ex.printStackTrace();
        }
          
          
           // do the final calculation
         FinalValue=(double)(value *result)/12;
           System.out.println("Tarifa a pagar:" + FinalValue);