public static String encodingString(String oldstring, String oldEncoding, String newEncoding) throws UnsupportedEncodingException { OutputStreamWriter outputStreamWriter = null; PublicMethod.myOutput(oldstring); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(oldstring.getBytes(oldEncoding)); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); InputStreamReader inputStreamRead = null; char cbuf[] = new char[1024]; int retVal = 0; try { inputStreamRead = new InputStreamReader(byteArrayInputStream, oldEncoding); outputStreamWriter = new OutputStreamWriter(byteArrayOutputStream, newEncoding); while ((retVal = inputStreamRead.read(cbuf)) != -1) { outputStreamWriter.write(cbuf, 0, retVal); } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { try { inputStreamRead.close(); outputStreamWriter.close(); } catch (Exception e) { // TODO: handle exception } ; } String temp = null; try { temp = new String(byteArrayOutputStream.toByteArray(), newEncoding); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } PublicMethod.myOutput("temp" + temp); return temp; }
public static String[] splitBetCodeTC(String pns) { PublicMethod.myOutput("?????????????????????????"); String[] tmp = null; try { Vector vector = new Vector(); int sIndex = 0; int eIndex = 0; String tempS = null; boolean flag = false; for (int i = 0; i < pns.length(); i++) { if (pns.charAt(i) == ';') { flag = true; eIndex = i; tempS = pns.substring(sIndex, eIndex); if (!tempS.equals("")) { vector.addElement(tempS); } sIndex = eIndex + 1; } if (flag) if (i == pns.length() - 1) { tempS = pns.substring(sIndex, i + 1); if (!tempS.equals("")) { vector.addElement(tempS); } } } if (!flag) { tempS = pns; if (!tempS.equals("")) { vector.addElement(tempS); } } tmp = new String[vector.size()]; for (int i = 0; i < vector.size(); i++) { tmp[i] = (String) vector.elementAt(i); } } catch (Exception e) { e.printStackTrace(); } return tmp; }
public static String makeString(String strLotteryType, int wayCode, String str) { String tmp = ""; if (strLotteryType.equals("F47104")) { if (wayCode == 00) { // µ¥Ê½ for (int i = 0; i < str.length(); ) { if (str.charAt(i) == '~') { i++; } if (i < str.length() - 2) { tmp += str.substring(i, i + 2) + " "; } else if (i == str.length() - 2) { tmp += " | " + str.substring(i, i + 2); } PublicMethod.myOutput("--------temp" + tmp); i += 2; } } else if (wayCode == 40 || wayCode == 50) { // µ¨ÍÏ for (int i = 0; i < str.length(); ) { if (i < str.length() - 2) { tmp += str.substring(i, i + 2) + ","; } else if (i == str.length() - 2) { tmp += str.substring(i, i + 2); } i += 2; } } else { for (int i = 0; i < str.length(); ) { if (i < str.length() - 2) { tmp += str.substring(i, i + 2) + ","; } else if (i == str.length() - 2) { tmp += str.substring(i, i + 2); } i += 2; } } } else if (strLotteryType.equals("F47103")) { for (int i = 0; i < str.length(); ) { if (i < str.length() - 2) { // fulei tmp += str.substring(i, i + 2); } else if (i == str.length() - 2) { tmp += str.substring(i, i + 2); } i += 2; } } else if (strLotteryType.equals("F47102")) { for (int i = 0; i < str.length(); ) { if (i < str.length() - 2) { tmp += str.substring(i, i + 2) + ","; } else if (i == str.length() - 2) { tmp += str.substring(i, i + 2); } i += 2; } } else if (strLotteryType.equals("T01001")) { int iStr = 0; for (int i = 0; i < str.length(); i++) { if (str.charAt(i) == '-') { iStr = i; } } tmp = str.substring(0, iStr) + "|" + str.substring(iStr + 1); System.out.println("-----tmp------" + tmp); } else if (strLotteryType.equals("T01002")) { tmp = str.substring(2); } return tmp; }