csvフォーマット

1827 ワード

// 1

String targetNumber1 = "13459265222";

String sendNumber1 = "106589658";

String content1 = " , 1";



// 2

String targetNumber2 = "13459265223";

String sendNumber2 = "106589659";

String content2 = " , 2";



StringBuffer csvStr = new StringBuffer();



// 1

csvStr.append(targetNumber1).append("|").append(sendNumber1).append("|").append(URLEncoder.encode(content1, "utf-8"));

// 

csvStr.append("\r
"); // 2 csvStr.append(targetNumber2).append("|").append(sendNumber2).append("|").append(URLEncoder.encode(content2, "utf-8")); //base64 String massInfo = Base64.encode(csvStr.toString()); System.out.println(massInfo); String str = Base64.decode("RDEzMkYxRDFFODE4NkU5OTU3QTAyQTgyMjQ3QkY1MkY4NkNENjc3NE1UTTBOVGt5TmpVeU1qSjhNVEEyTlRnNU5qVTRmQ1ZGT0NWQ1JpVTVPU1ZGTmlVNU9DVkJSaVZGTkNWQ09DVTRNQ1ZGTmlVNVJDVkJNU1ZGTnlWQ1JTVkJOQ1ZGTlNVNFJpVTVNU1ZGTmlWQ05TVTRRaVZGT0NWQlJpVTVOU1ZGTnlVNVJpVkJSQ1ZGTkNWQ1JpVkJNU1V5UXlWRk55VTVSaVZCUkNWRk5DVkNSaVZCTVRFTkNqRXpORFU1TWpZMU1qSXpmREV3TmpVNE9UWTFPWHdsUlRnbFFrWWxPVGtsUlRZbE9UZ2xRVVlsUlRRbFFqZ2xPREFsUlRZbE9VUWxRVEVsUlRjbFFrVWxRVFFsUlRVbE9FWWxPVEVsUlRZbFFqVWxPRUlsUlRnbFFVWWxPVFVsUlRjbE9VWWxRVVFsUlRRbFFrWWxRVEVsTWtNbFJUY2xPVVlsUVVRbFJUUWxRa1lsUVRFeQ=="); System.out.println(str); String records[] = str.split("\r
"); for(String record: records){ String fields[] = record.split("\\|"); System.out.println("============================="); for(String field: fields){ if(field.length() > 20){ field = URLDecoder.decode(field, "utf-8"); } System.out.println(field); } System.out.println("============================="); }