Bonsoir la famille

je fais un site en java web (JSP servlet), je fais une extraction en CSV en mettant ;
il se trouve certaines colonnes ou il y'a des nombres commencants par 0 et j'ai pu trouver un solution pour garder le 0

en utilisant cette Mon probleme est :

je veux que cette colonne soit en format texte
comment puis-je proceder

Merci


Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
Connection conn = null;
        Statement ss = null;
 
        String dateStar11 = request.getParameter("dateStar11");
        String dateStar22 = request.getParameter("dateStar22");
 
        String url = "http://localhost/withdraw/list/b005fd07f0";
 
        try {
            Class.forName("com.mysql.jdbc.Driver");
            conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/bd", "root", "");
            ss = conn.createStatement();
 
            PreparedStatement pst = conn.prepareStatement("Select * from code ORDER BY code DESC LIMIT 1");
 
            ResultSet rs = pst.executeQuery();
 
            if (rs.next()) {
 
                Integer code = rs.getInt("code");
 
                Date datee = new Date();
 
                String DateJour = String.valueOf(datee);
 
                SimpleDateFormat s = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.US);
                SimpleDateFormat ou = new SimpleDateFormat("ddMMyyyy");
                SimpleDateFormat hh = new SimpleDateFormat("HHmmss");
 
                Date d = s.parse(DateJour);
 
                String formatJour = ou.format(d);
                String formatHeure = hh.format(d);
 
                // TODO Auto-generated method stub
                System.out.println("************** doGet ************");
                response.setContentType("text/csv; charset=UTF-8");
                PrintWriter out = response.getWriter();
                response.setDateHeader("Expires", 0);
 
                StringBuffer fileNameFormat = new StringBuffer();
                fileNameFormat.append("attachment; filename=63_Salary_" + formatJour + "_" + formatHeure);
                fileNameFormat.append(".csv");
                response.setHeader("Content-disposition", fileNameFormat.toString());
 
                StringBuffer totalString = new StringBuffer();
                StringBuffer header = new StringBuffer();
 
                header.append("Mobile Number*");
                header.append(";");
                header.append("Amount*");
                header.append(";");
                header.append("First Name");
                header.append(";");
                header.append("Last Name");
                header.append(";");
                header.append("Id Number");
                header.append(";");
                header.append("Remarks*");
                header.append(";");
                header.append("User Type*");
 
                StringBuffer body = new StringBuffer();
 
                HttpClient client = HttpClientBuilder.create().build();
                HttpPost post = new HttpPost(url);
 
                //String USER_AGENT = "";
                // add header
                post.setHeader("User-Agent", "Mozilla/5.0");
 
                List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
 
                urlParameters.add(new BasicNameValuePair("from", dateStar11));
                urlParameters.add(new BasicNameValuePair("to", dateStar22));
                urlParameters.add(new BasicNameValuePair("status", "pending"));
                post.setEntity(new UrlEncodedFormEntity(urlParameters));
 
                HttpResponse respons = client.execute(post);
                System.out.println("Response Code : " + respons.getStatusLine().getStatusCode());
 
                BufferedReader rd = new BufferedReader(new InputStreamReader(respons.getEntity().getContent()));
 
                String resu = "";
 
                StringBuffer result = new StringBuffer();
                String line = "";
                while ((line = rd.readLine()) != null) {
                    System.out.println(result.append(line));
                    resu += line;
                }
                rd.close();
 
                String weatherResult = resu;
 
                System.out.println(weatherResult);
 
                // read the json file
                JSONParser jsonParser = new JSONParser();
 
                JSONArray array = (JSONArray) jsonParser.parse(weatherResult);
 
                Iterator i = array.iterator();
 
                int ii = code + 1;
 
                while (i.hasNext()) {
 
                    JSONObject innerObj = (JSONObject) i.next();
                    System.out.println("cashout_account_number " + innerObj.get("cashout_account_number"));
                    String cashout_account_number = (String) innerObj.get("cashout_account_number");
                    System.out.println("mt_momo " + innerObj.get("mt_momo"));
                    Double transaction_amount = (Double) innerObj.get("mt_momo");
                    System.out.println("transaction_type " + innerObj.get("transaction_type"));
                    Long transaction_type = (Long) innerObj.get("transaction_type");
 
                    DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.FRANCE);
                    DecimalFormatSymbols symbols = formatter.getDecimalFormatSymbols();
 
                    symbols.setGroupingSeparator(' ');
                    formatter.setDecimalFormatSymbols(symbols);
 
                    String gross_amount3 = formatter.format(transaction_amount.doubleValue());
                    //String number = formatter.format(cashout_account_number.toString());
 
                    if (transaction_type == 2 && cashout_account_number != null) {
 
                        body.append(""+cashout_account_number + "\t");
                        body.append(";");
                        body.append(gross_amount3);
                        body.append(";");
                        body.append("");
                        body.append(";");
                        body.append("");
                        body.append(";");
                        body.append(ii++);
                        body.append(";");
                        body.append("salaire");
                        body.append(";");
                        body.append("Subscriber");
                        body.append("\n");
 
                    }
 
                }
 
                totalString.append(header.toString());
                totalString.append("\n");
                totalString.append(body.toString());
                out.write(totalString.toString());
 
            }
 
        } catch (ParseException ex) {
        }