This reads lines from a file, create HTTP sessions and post data on a website. The code is slow, so please suggest how I can improve the performance.package test_reg;import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;import java.net.URI;import java.net.URISyntaxException;import java.text.DateFormat;import java.text.SimpleDateFormat;import java.util.Calendar;import java.util.Date;import java.util.Iterator;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpSession;import javax.servlet.http.HttpServletResponse;import org.apache.http.HttpResponse;import org.apache.http.client.ClientProtocolException;import org.apache.http.client.HttpClient;import org.apache.http.client.methods.HttpPost;import org.apache.http.client.methods.HttpPut;import org.apache.http.client.utils.URIUtils;import org.apache.http.entity.StringEntity;import org.apache.http.impl.client.DefaultHttpClient;import org.apache.http.util.EntityUtils;import java.util.*;import org.apache.poi.hssf.usermodel.HSSFSheet;import org.apache.poi.xssf.usermodel.XSSFSheet;import org.apache.poi.xssf.usermodel.XSSFWorkbook;import org.apache.poi.hssf.usermodel.HSSFWorkbook;import org.apache.poi.ss.usermodel.Cell;import org.apache.poi.ss.usermodel.Row;import org.json.JSONException;import org.json.JSONObject;//import com.clm24.core.Person;public class test_reg {    public static void main(String[] args)            throws URISyntaxException, ClientProtocolException, IOException, JSONException {        /*         * public static void autoRegistration(HttpServletRequest request,         * HttpServletResponse response) throws Throwable {         *          * HttpSession session = request.getSession();         */        // Reading data from input file        File f = new File(C:\\maharastra\\mumbai.xlsx);        if (!f.exists()) {            System.out.println(Cannot locate input excel );        } else {            FileInputStream input = new FileInputStream(f);            // POIFSFileSystem fs = new POIFSFileSystem( input );            // HSSFWorkbook wb = new HSSFWorkbook(fs);            XSSFWorkbook wb = new XSSFWorkbook(input);            // HSSFSheet sheet = wb.getSheetAt(0);            XSSFSheet sheet = (XSSFSheet) wb.getSheetAt(0);            Iterator<Row> iterator = sheet.iterator();            HSSFWorkbook workbook = new HSSFWorkbook();            HSSFSheet reg_sheet = workbook.createSheet(AutoRegistered_Data);            Row row;            Row export_row;            int rowCount = 0;            int columnCount = 0;            // String phonenumber = ;            DateFormat df = new SimpleDateFormat(yyyy/MM/dd HH:mm:ss);            String birthday = ;            // Read data from excel            while (iterator.hasNext()) {                String phonenumber = ;                row = iterator.next();                int reg_columnCount = 0;                String fullName = row.getCell(0).getStringCellValue();                int firstSpace = fullName.indexOf( ); // detect the first                                                        // space character                String firstName = ;                String lastName = ;                if (firstSpace > 0) {                    firstName = fullName.substring(0, firstSpace); // get                                                                    // everything                                                                    // upto the                                                                    // first                                                                    // space                                                                    // character                    lastName = fullName.substring(firstSpace); // get everything                                                                // after the                                                                // first space,                                                                // trimming the                                                                // spaces off                } else {                    firstName = fullName;                    lastName = --;                }                System.out.println(Reading firstName :  + firstName);                System.out.println(Reading lastName  :  + lastName);                String email_add = row.getCell(1).getStringCellValue();                System.out.println(Reading email address :  + email_add);                /*if (StringUtil.isNull(email_add) || email_add.equals()) {                    break;                }*/                /*                 * Cell cell = row.getCell(4); if                 * ((StringUtil.isBlank(row.getCell(4).getStringCellValue())) ||                 * (row.getCell(4).getStringCellValue()).equals()) { } else {                 * if ((cell.getCellType() == Cell.CELL_TYPE_STRING)) {                 *                  *                  * String phonenum = row.getCell(4).getStringCellValue();                 *                  * phonenumber = phonenum.replaceAll([^0-9], );                 * System.out.println(Reading string phone number :  +                 * phonenumber); } // break;                 *                  * if ((cell.getCellType() == Cell.CELL_TYPE_NUMERIC)) { double                 * phonenumb = row.getCell(4).getNumericCellValue(); phonenumber                 * = Double.toString(phonenumb); phonenumber =                 * phonenumber.replaceAll([^0-9], ); // phonenumber =                 * phonenumber.concat(91); System.out.println(                 * Reading double phone number :  + phonenumber); } }                 */                Cell cell = row.getCell(4);                switch (cell.getCellType()) {                case Cell.CELL_TYPE_STRING:                    String phonenum = row.getCell(4).getStringCellValue();                    phonenumber = phonenum.replaceAll([^0-9], );                    System.out.println(Reading string phone number :  + phonenumber);                    break;                case Cell.CELL_TYPE_NUMERIC:                    double phonenumb = row.getCell(4).getNumericCellValue();                    phonenumber = Double.toString(phonenumb);                    phonenumber = phonenumber.replaceAll([^0-9], );                    // phonenumber = phonenumber.concat(91);                    System.out.println(Reading double phone number :  + phonenumber);                    break;                }                Date dob = row.getCell(3).getDateCellValue();                String education = row.getCell(17).getStringCellValue();                String gender = row.getCell(26).getStringCellValue();                String address_1 = row.getCell(28).getStringCellValue();                System.out.println(Reading address_1  :  + address_1);                String city = row.getCell(15).getStringCellValue();                /*if (StringUtil.isNull(address_1) || address_1.equals( )) {                    break;                }*/                // To do String name = row.getCell(0).getStringCellValue();                birthday = df.format(dob);                System.out.println(Reading dob  :  + birthday);                System.out.println(Reading address_1  :  + address_1);                System.out.println(Reading city  :  + city);                String zipCode = 400096;                /*                 * String zipCode = address_1.trim(); int space =                 * zipCode.lastIndexOf(-); // detect the first space character                 * zipCode = zipCode.substring(space); // get everything upto                 * the first space character zipCode = zipCode.replace(-, );                 */                // zipCode = zipCode.substring(zipCode.length(),6);                System.out.println(Reading zip code  :  + zipCode);                // Adding user data to registration object                JSONObject regDetails = new JSONObject();                regDetails.put(referredBy, );                regDetails.put(phone_number, phonenumber);                regDetails.put(password, ZO25L2);                regDetails.put(newFlow, true);                regDetails.put(lastName, lastName);                regDetails.put(firstName, firstName);                regDetails.put(email_address, email_add);                regDetails.put(birthday, birthday);                regDetails.put(education, education);                regDetails.put(gender, gender);                // Adding address details                JSONObject addressDetails = new JSONObject();                addressDetails.put(address_1, address_1);                addressDetails.put(address_type_id, 1);                addressDetails.put(city, city);                addressDetails.put(country_code, 356);                addressDetails.put(is_primary, true);                addressDetails.put(state_code, 3880);                addressDetails.put(zip_code, zipCode);                JSONObject googleParamas = new JSONObject();                // HttpEntity e = new StringEntity(json.toString());                HttpClient httpSessionClient = null;                httpSessionClient = new DefaultHttpClient();                HttpPost httpSessionMethod = null;                String regDetailparam = { + RegistrationDetails + : + regDetails + , addressDetails + :                        + addressDetails + , extraGoogleParams + : + googleParamas + };                JSONObject registrationDetails = new JSONObject(regDetailparam);                URI uri = URIUtils.createURI(null,                        https://app.ship2myid.com/ship2myid/client/rest/webclient/autoregister_full, -1, null,                        reg_source=email, null);                // String urlPath =                // URLEncoder.encode(registrationDetails.toString(), UTF-8);                httpSessionMethod = new HttpPost(uri);                System.out.println(URL + httpSessionMethod);                StringEntity se = new StringEntity(registrationDetails.toString());                // sets the post request as the resulting string                httpSessionMethod.setEntity(se);                httpSessionMethod.setHeader(Accept, application/json);                httpSessionMethod.setHeader(Content-type, application/json);                HttpResponse httpResponseSession = httpSessionClient.execute(httpSessionMethod);                System.out.println(Response + httpResponseSession);                String regResult = EntityUtils.toString(httpResponseSession.getEntity());                System.out.println(result + regResult);                JSONObject jsonResult = new JSONObject(regResult);                 if(jsonResult.has(session_id)){                 String session_id = jsonResult.getString(session_id);                 System.out.println( session_id  +session_id);                 //---------                 HttpPut httpDeleteSession = null;                 URI uriDelete = URIUtils.createURI(null,                   https://app.ship2myid.com/ship2myid/client/rest/session/signout, -1, null,                   access_token=+session_id, null);                 httpDeleteSession = new HttpPut(uriDelete);                 HttpResponse httpResponse = httpSessionClient.execute(httpDeleteSession);                 String delResult = EntityUtils.toString(httpResponse.getEntity());                 System.out.println( DELETE   + delResult);                }                //----------                // Writing result to Excel                export_row = reg_sheet.createRow(rowCount++);                Cell email_cell = export_row.createCell(columnCount);                Cell result_cell = export_row.createCell(reg_columnCount + 1);                email_cell.setCellValue(email_add);                result_cell.setCellValue(regResult);            }            wb.close();            input.close();            FileOutputStream out = new FileOutputStream(                    new File(E:\\Book1_Auto_Reg_Result.xlsx));            workbook.write(out);            out.close();            // workbook.close();            System.out.println(Auto_Reg_Result.xls written successfully on disk.);        }    }}
Posting HTTP session data on a website
java;http