隨筆-71  評(píng)論-5  文章-0  trackbacks-0
           

          /Files/kokosang/html5拖拽上傳.zip

            前幾天想做個(gè)給安卓app升級(jí)做個(gè)上傳頁面,然后從網(wǎng)上down了個(gè)頁面下面(主要是嫌棄自己頁面整的太丑,見不了人),然后就一直在整后臺(tái)取值的辦法
            各種百度,值取出來了,但是,悲催的是總是亂碼,崩潰了,大神看了后,鄙視一番,給我整了下,簡(jiǎn)直就是重寫了

            貼出來,先放張頁面效果
            


            賞心悅目的后臺(tái)來咯

          import java.io.BufferedWriter;
          import java.io.File;
          import java.io.FileOutputStream;
          import java.io.IOException;
          import java.io.InputStream;
          import java.io.OutputStream;
          import java.io.OutputStreamWriter;
          import java.util.List;

          import org.apache.log4j.Logger;
          import org.apache.tomcat.util.http.fileupload.FileItem;
          import org.apache.tomcat.util.http.fileupload.disk.DiskFileItemFactory;
          import org.apache.tomcat.util.http.fileupload.servlet.ServletFileUpload;

          import com.puff.framework.annotation.Controller;
          import com.puff.web.mvc.PuffContext;
          import com.puff.web.view.View;

          @Controller("/upload/android")
          public class AndroidVersionUploadController {

              private static final Logger logger = Logger.getLogger(UserImageController.class);
              
              private static final String FILE_PATH = "C:/Users/Administrator/Desktop";
              
              private static final String FILE_APK_NAME = "/nn.apk";
              private static final String FILE_VER_NAME = "/ver.txt";
              
              /**
               * 版本上傳
               * 
          @return
               * 
          @throws Exception 
               
          */
              public View update() throws Exception {
                  DiskFileItemFactory factory = new DiskFileItemFactory(); 
                  ServletFileUpload upload = new ServletFileUpload(factory); 
                  List<FileItem> items = upload.parseRequest( PuffContext.getRequest()); 
                  
                  String ver = null;
                  String info = null;
                  String isFoucs = null;
                  for(Object object : items) { 
                      FileItem fileItem = (FileItem)object; 
                      if(fileItem.isFormField()) { 
                          
                          String name = fileItem.getFieldName();
                          String value = fileItem.getString("utf-8");
                          
                          if("ver".equals(name)){
                              ver = value;
                          }else if("content".equals(name)){
                              info = value;
                          }else if("radio".equals(name)){
                              isFoucs = value;
                          }
                      } else {
                          saveFileInfo(fileItem);
                      }
                  } 
                  
                  saveContentInfo(ver, info, isFoucs);
                  
                  return null;
              
              }

              private void saveFileInfo(FileItem fileItem) {
                  
                  InputStream is = null;
                  OutputStream os = null;
                  try {
                      File file = new File(FILE_PATH);
                      if(file.exists()) {
                          file.mkdirs();
                      }
                      
                      is = fileItem.getInputStream();
                      os = new FileOutputStream(FILE_PATH + FILE_APK_NAME);
                      
                      int len = 0;
                      byte[] buffer = new byte[8 * 1024];
                      while ((len = is.read(buffer, 0, 8 * 1024)) != -1) {
                          os.write(buffer, 0, len);
                      }
                  } catch (Exception e) {
                      e.printStackTrace();
                  } finally {
                      closeOutputStream(os);
                      closeInputStream(is);
                  }
              }
              
              public void saveContentInfo(String ver, String info, String isFoucs) {
                  BufferedWriter br = null;
                  try {
                      File file = new File(FILE_PATH);
                      if(file.exists()) {
                          file.mkdirs();
                      }
                      
                      br = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(FILE_PATH + FILE_VER_NAME), "utf-8"));
                      br.write("ver:" + ver + "\r\n");   //版本號(hào)
                      br.write("update:" + isFoucs+ "\r\n");   //是否強(qiáng)制更新
                      br.write("content:" + info );    //版本升級(jí)內(nèi)容
                      br.flush();
                  } catch (Exception e) {
                      e.printStackTrace();
                  } finally {
                      try {
                          if(br != null) {
                              br.close();
                          }
                      } catch (IOException e) {
                          e.printStackTrace();
                      } finally {
                          br = null;
                      }
                  }
              }


              private void closeOutputStream(OutputStream os) {
                  if(os != null) {
                      try {
                          os.close();
                      } catch (IOException e) {
                          e.printStackTrace();
                      } finally {
                          os = null;
                      }
                  }
              }
              
              private void closeInputStream(InputStream is) {
                  if(is != null) {
                      try {
                          is.close();
                      } catch (IOException e) {
                          e.printStackTrace();
                      } finally {
                          is = null;
                      }
                  }
              }
          }
          posted @ 2015-08-24 10:35 藤本薔薇 閱讀(261) | 評(píng)論 (0)編輯 收藏
          public static void main(String[] args) {

                  String xml = "<?xml version=\"1.0\" encoding=\"gb2312\"?><p><seqid></seqid><code></code><msg>成功</msg>" +
                                    "<node><ename>huoniu</ename><cname>火牛</cname><prefix>108</prefix><begin>20150603</begin><end>20160630</end><borr>1000000</borr><margin>100000</margin><usdborr>1000000</usdborr><usdmargin>100000</usdmargin><mainp>0.60</mainp><midp>0.60</midp><growp>0.60</growp><mainpt>0.60</mainpt><midpt>0.60</midpt><growpt>0.30</growpt><shcomm>0.000300</shcomm><szcomm>0.000300</szcomm><warn>1.000</warn><close>1.000</close><interest>200</interest><commf>13</commf><layout>p-huo01:1100000:574810</layout><unmoney>0</unmoney><tstatus>0</tstatus><cstatus>0</cstatus></node>" +
                                    " <node><ename>nn</ename><cname>牛牛</cname><prefix>102</prefix><begin>20150615</begin><end>20151015</end><borr>10000000</borr><margin>8000000</margin><usdborr>10000000</usdborr><usdmargin>8000000</usdmargin><mainp>0.60</mainp><midp>0.60</midp><growp>0.30</growp><mainpt>0.60</mainpt><midpt>0.60</midpt><growpt>0.30</growpt><shcomm>0.003000</shcomm><szcomm>0.003000</szcomm><warn>0.800</warn><close>0.800</close><interest>0</interest><commf>0</commf><layout></layout><unmoney>18000000</unmoney><tstatus>0</tstatus><cstatus>0</cstatus></node>" +
                                   "<node><ename>ag-huo</ename><cname>兜底代理商</cname><prefix>huo</prefix><begin>20150602</begin><end>20160630</end><borr>0</borr><margin>0</margin><usdborr>0</usdborr><usdmargin>0</usdmargin><mainp>0.60</mainp><midp>0.60</midp><growp>0.30</growp><mainpt>0.60</mainpt><midpt>0.60</midpt><growpt>0.30</growpt><shcomm>0.000300</shcomm><szcomm>0.000300</szcomm><warn>0.010</warn><close>0.010</close><interest>0</interest><commf>0</commf><layout></layout><unmoney>0</unmoney><tstatus>0</tstatus><cstatus>0</cstatus></node></p>";

                  List<Map> nodeList = new ArrayList<Map>();
                  Map<String, Object> sendMap = new HashMap<String, Object>();
                  try {
                      
                      DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                      DocumentBuilder db = dbf.newDocumentBuilder();
                      Document doc = db.parse(new InputSource(new StringReader(xml)));
                      Element root = doc.getDocumentElement();// 根節(jié)點(diǎn)

                      Node node = root.getFirstChild();
                      while(node != null) {
                          String nodeName = node.getNodeName().trim();
                          String nodeValue = node.getTextContent().trim();
                          
                          if("node".equals(nodeName) && node.hasChildNodes()) {
                              
                              Map<String, Object> nodeMap = new HashMap<String, Object>();
                              
                              Node childNode = node.getFirstChild();
                              while(childNode != null) {
                                  nodeMap.put(childNode.getNodeName(), childNode.getTextContent());
                                  childNode = childNode.getNextSibling();
                              }
                              
                              nodeList.add(nodeMap);
                          } else {
                              sendMap.put(nodeName, nodeValue);
                          }
                          
                          node = node.getNextSibling();
                      }
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
                  
                  sendMap.put("node", nodeList);
                  
                  System.out.println(sendMap);
              }



          打印結(jié)果 :
          {node=[{warn=1.000, cstatus=0, tstatus=0, borr=1000000, growpt=0.30, unmoney=0, midpt=0.60, usdmargin=100000, commf=13, close=1.000, begin=20150603, shcomm=0.000300, usdborr=1000000, growp=0.60, interest=200, layout=p-huo01:1100000:574810, prefix=108, ename=huoniu, midp=0.60, mainpt=0.60, margin=100000, szcomm=0.000300, cname=火牛, end=20160630, mainp=0.60}, 
                      {warn=0.800, cstatus=0, tstatus=0, borr=10000000, growpt=0.30, unmoney=18000000, midpt=0.60, usdmargin=8000000, commf=0, close=0.800, begin=20150615, shcomm=0.003000, usdborr=10000000, growp=0.30, interest=0, layout=, ename=nn, midp=0.60, mainpt=0.60, margin=8000000, szcomm=0.003000, end=20151015, mainp=0.60},
                      {warn=0.010, cstatus=0, tstatus=0, borr=0, growpt=0.30, unmoney=0, midpt=0.60, usdmargin=0, commf=0, close=0.010, begin=20150602, shcomm=0.000300, usdborr=0, growp=0.30, interest=0, layout=, prefix=huo, ename=ag-huo, midp=0.60, mainpt=0.60, margin=0, szcomm=0.000300, end=20160630, mainp=0.60}], seqid=, code=, msg=成功}
          posted @ 2015-08-09 10:15 藤本薔薇 閱讀(266) | 評(píng)論 (0)編輯 收藏
                public static void main(String[] args) throws Exception {
                      Map<String, Object> sendMap = new HashMap<String, Object>();
                      String data = "<?xml version=\"1.0\" encoding=\"gb2312\"?><p><seqid></seqid><client>0BF3F2D9A01797BBF05D6BC89877DC91</client><ename>108-wc</ename><code>0</code><msg>成功</msg><totalm>12447.97</totalm><cash>5669.13</cash><stockm>6778.84</stockm><num>2</num><stock><node><market>0</market><symbol>600104</symbol><direct>1</direct><type>0</type><avgprice>21.010</avgprice><holdnum>299</holdnum></node><node><market>0</market><symbol>601818</symbol><direct>1</direct><type>0</type><avgprice>4.993</avgprice><holdnum>4</holdnum></node></stock></p>";

                      List<Map> nodeList = new ArrayList<Map>();
                      try {
                          DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                          DocumentBuilder db = dbf.newDocumentBuilder();
                          Document doc = db.parse(new InputSource(new StringReader(data)));
                          Element root = doc.getDocumentElement();// 根節(jié)點(diǎn)
                          Node node = root.getFirstChild();
                          while(node != null) {
                              String nodeName = node.getNodeName().trim();
                              String nodeValue = node.getTextContent().trim();
                              if("stock".equals(nodeName) && node.hasChildNodes()) {
                                  Node  nodeOne =  node.getFirstChild();
                                  while(nodeOne != null) {
                                   String nodeOneName = nodeOne.getNodeName().trim();
                                   if("node".equals(nodeOneName) && nodeOne.hasChildNodes()){
                                       Map<String, Object> nodeMap = new HashMap<String, Object>();
                                        Node threeNode = nodeOne.getFirstChild();
                                          while(threeNode != null) {
                                              nodeMap.put(threeNode.getNodeName(), threeNode.getTextContent());
                                              threeNode = threeNode.getNextSibling();
                                          }
                                          nodeList.add(nodeMap);
                                        }
                                     nodeOne = nodeOne.getNextSibling();
                                     }
                                  }else{
                                      sendMap.put(nodeName, nodeValue);
                                  }
                              node = node.getNextSibling();
                              }                    
                          sendMap.put("node", nodeList);
                      } catch (Exception e) {
                          e.printStackTrace();
                      }
                      System.out.println(sendMap);
                }  


          打印結(jié)果:{node=[{direct=1, market=0, symbol=600104, avgprice=21.010, holdnum=299, type=0},
                       {direct=1, market=0, symbol=601818, avgprice=4.993, holdnum=4, type=0}],
                        num=2, seqid=, client=0BF3F2D9A01797BBF05D6BC89877DC91, stockm=6778.84, cash=5669.13, ename=108-wc, code=0, totalm=12447.97, msg=成功}
          posted @ 2015-08-09 10:09 藤本薔薇 閱讀(476) | 評(píng)論 (0)編輯 收藏
          /Files/kokosang/DoubleUtil.txt



          package frameWork.util;
          import java.math.BigDecimal;
          import java.text.DecimalFormat;
          /**   
           * 由于Java的簡(jiǎn)單類型不能夠精確的對(duì)浮點(diǎn)數(shù)進(jìn)行運(yùn)算,這個(gè)工具類提供精   
           * 確的浮點(diǎn)數(shù)運(yùn)算,包括加減乘除和四舍五入。   
           */    
          public class DoubleUtil {
          //這個(gè)類不能實(shí)例化    
          private DoubleUtil(){    
          }  
          //默認(rèn)除法運(yùn)算精度    
          private static final int DEF_DIV_SCALE = 10;  
          //默認(rèn)的保留位數(shù)
          private static DecimalFormat df=new DecimalFormat("0.00");  
          /**
          * 按照格式保留幾位
          * @param money  double數(shù)
          * @param format 格式
          * @return
          */
          public static double  format(double money,String format){
          if(format != null && format != ""){
          df=new DecimalFormat(format); 
          }
          double moneyformat=new Double(df.format(money).toString());  
          return moneyformat;
          }
          /**   
          * 提供精確的加法運(yùn)算。   
          * @param v1 被加數(shù)   
          * @param v2 加數(shù)   
          * @return 兩個(gè)參數(shù)的和   
          */    
          public static double add(double v1,double v2){    
          BigDecimal b1 = new BigDecimal(Double.toString(v1));    
          BigDecimal b2 = new BigDecimal(Double.toString(v2));    
          return b1.add(b2).doubleValue();    
          }    
          /**   
          * 提供精確的減法運(yùn)算。   
          * @param v1 被減數(shù)   
          * @param v2 減數(shù)   
          * @return 兩個(gè)參數(shù)的差   
          */    
          public static double sub(double v1,double v2){    
          BigDecimal b1 = new BigDecimal(Double.toString(v1));    
          BigDecimal b2 = new BigDecimal(Double.toString(v2));    
          return b1.subtract(b2).doubleValue();    
          }    
          /**   
          * 提供精確的乘法運(yùn)算。   
          * @param v1 被乘數(shù)   
          * @param v2 乘數(shù)   
          * @return 兩個(gè)參數(shù)的積   
          */    
          public static double mul(double v1,double v2){    
          BigDecimal b1 = new BigDecimal(Double.toString(v1));    
          BigDecimal b2 = new BigDecimal(Double.toString(v2));    
          return b1.multiply(b2).doubleValue();    
          }    
          /**   
          * 提供(相對(duì))精確的除法運(yùn)算,當(dāng)發(fā)生除不盡的情況時(shí),精確到   
          * 小數(shù)點(diǎn)以后10位,以后的數(shù)字四舍五入。   
          * @param v1 被除數(shù)   
          * @param v2 除數(shù)   
          * @return 兩個(gè)參數(shù)的商   
          */    
          public static double div(double v1,double v2){    
          return div(v1,v2,DEF_DIV_SCALE);    
          }    
          /**   
          * 提供(相對(duì))精確的除法運(yùn)算。當(dāng)發(fā)生除不盡的情況時(shí),由scale參數(shù)指   
          * 定精度,以后的數(shù)字四舍五入。   
          * @param v1 被除數(shù)   
          * @param v2 除數(shù)   
          * @param scale 表示表示需要精確到小數(shù)點(diǎn)以后幾位。   
          * @return 兩個(gè)參數(shù)的商   
          */    
          public static double div(double v1,double v2,int scale){    
          if(scale<0){    
          throw new IllegalArgumentException("The scale must be a positive integer or zero");    
          }    
          BigDecimal b1 = new BigDecimal(Double.toString(v1));    
          BigDecimal b2 = new BigDecimal(Double.toString(v2));    
          return b1.divide(b2,scale,BigDecimal.ROUND_HALF_UP).doubleValue();    
          }    
          /**   
          * 提供精確的小數(shù)位四舍五入處理。   
          * @param v 需要四舍五入的數(shù)字   
          * @param scale 小數(shù)點(diǎn)后保留幾位   
          * @return 四舍五入后的結(jié)果   
          */    
          public static double round(double v,int scale){    
          if(scale<0){    
          throw new IllegalArgumentException("The scale must be a positive integer or zero");    
          }    
          BigDecimal b = new BigDecimal(Double.toString(v));    
          BigDecimal one = new BigDecimal("1");    
          return b.divide(one,scale,BigDecimal.ROUND_HALF_UP).doubleValue();    
          }    
          /**   
          * 提供精確的類型轉(zhuǎn)換(Float)   
          * @param v 需要被轉(zhuǎn)換的數(shù)字   
          * @return 返回轉(zhuǎn)換結(jié)果   
          */    
          public static float convertsToFloat(double v){    
          BigDecimal b = new BigDecimal(v);    
          return b.floatValue();    
          }    
          /**   
          * 提供精確的類型轉(zhuǎn)換(Int)不進(jìn)行四舍五入   
          * @param v 需要被轉(zhuǎn)換的數(shù)字   
          * @return 返回轉(zhuǎn)換結(jié)果   
          */    
          public static int convertsToInt(double v){    
          BigDecimal b = new BigDecimal(v);    
          return b.intValue();    
          }    
          /**   
          * 提供精確的類型轉(zhuǎn)換(Long)   
          * @param v 需要被轉(zhuǎn)換的數(shù)字   
          * @return 返回轉(zhuǎn)換結(jié)果   
          */    
          public static long convertsToLong(double v){    
          BigDecimal b = new BigDecimal(v);    
          return b.longValue();    
          }    
          /**   
          * 返回兩個(gè)數(shù)中大的一個(gè)值   
          * @param v1 需要被對(duì)比的第一個(gè)數(shù)   
          * @param v2 需要被對(duì)比的第二個(gè)數(shù)   
          * @return 返回兩個(gè)數(shù)中大的一個(gè)值   
          */    
          public static double returnMax(double v1,double v2){    
          BigDecimal b1 = new BigDecimal(v1);    
          BigDecimal b2 = new BigDecimal(v2);    
          return b1.max(b2).doubleValue();    
          }    
          /**   
          * 返回兩個(gè)數(shù)中小的一個(gè)值   
          * @param v1 需要被對(duì)比的第一個(gè)數(shù)   
          * @param v2 需要被對(duì)比的第二個(gè)數(shù)   
          * @return 返回兩個(gè)數(shù)中小的一個(gè)值   
          */    
          public static double returnMin(double v1,double v2){    
          BigDecimal b1 = new BigDecimal(v1);    
          BigDecimal b2 = new BigDecimal(v2);    
          return b1.min(b2).doubleValue();    
          }    
          /**   
          * 精確對(duì)比兩個(gè)數(shù)字   
          * @param v1 需要被對(duì)比的第一個(gè)數(shù)   
          * @param v2 需要被對(duì)比的第二個(gè)數(shù)   
          * @return 如果兩個(gè)數(shù)一樣則返回0,如果第一個(gè)數(shù)比第二個(gè)數(shù)大則返回1,反之返回-1   
          */    
          public static int compareTo(double v1,double v2){    
          BigDecimal b1 = new BigDecimal(v1);    
          BigDecimal b2 = new BigDecimal(v2);    
          return b1.compareTo(b2);    
          }
          /**
          * 格式化double
          * @param arg0
          * @param num
          * @return
          */
          public static String doubleFormat(double arg0,Integer num){
          DecimalFormat df = new DecimalFormat("####.00"); 
          /*DecimalFormat df2 = new DecimalFormat("##.00%");  
          DecimalFormat df3 = new DecimalFormat("###,##0.00");*/
          if(num !=null){
          if(num == 1){
          df = new DecimalFormat("####.0"); 
          }else if(num == 2){
          df = new DecimalFormat("####.00"); 
          }else if(num == 3){
          df = new DecimalFormat("####.000"); 
          }else if(num == 4){
          df = new DecimalFormat("####.0000"); 
          }
          }else{
          df = new DecimalFormat("####"); 
          }
          if(df.format(arg0).contains(".")){
          if(df.format(arg0).substring(0, df.format(arg0).indexOf(".")).length()<=0){
          df = new DecimalFormat("0.00");
          if(num !=null){
          if(num == 1){
          df = new DecimalFormat("0.0"); 
          }else if(num == 2){
          df = new DecimalFormat("0.00"); 
          }else if(num == 3){
          df = new DecimalFormat("0.000"); 
          }else if(num == 4){
          df = new DecimalFormat("0.0000"); 
          }
          }else{
          df = new DecimalFormat("0"); 
          }
          }
          }
          return df.format(arg0);
          }
          /**
          * 百分比格式化
          * @param arg0
          * @param num
          * @return
          */
          public static String percentageFormat(double arg0,Integer num){
          DecimalFormat df = new DecimalFormat("##.00%");
          if(num !=null){
          if(num == 1){
          df = new DecimalFormat("####.0%"); 
          }else if(num == 2){
          df = new DecimalFormat("####.00%"); 
          }else if(num == 3){
          df = new DecimalFormat("####.000%"); 
          }else if(num == 4){
          df = new DecimalFormat("####.0000%"); 
          }
          }else{
          df = new DecimalFormat("####%"); 
          }
          if(df.format(arg0).contains(".")){
          if(df.format(arg0).substring(0, df.format(arg0).indexOf(".")).length()<=0){
          df = new DecimalFormat("0.00%");
          if(num !=null){
          if(num == 1){
          df = new DecimalFormat("0.0%"); 
          }else if(num == 2){
          df = new DecimalFormat("0.00%"); 
          }else if(num == 3){
          df = new DecimalFormat("0.000%"); 
          }else if(num == 4){
          df = new DecimalFormat("0.0000%"); 
          }
          }else{
          df = new DecimalFormat("0%"); 
          }
          }
          }
          return df.format(arg0);
          }
          /**
          * double每三位短號(hào)分割
          * @param arg0
          * @param num
          * @return
          */
          public static String splitNumberFormat(double arg0,Integer num){
          DecimalFormat df = new DecimalFormat("###,##0.00");
          if(num !=null){
          if(num == 1){
          df = new DecimalFormat("###,##0.0"); 
          }else if(num == 2){
          df = new DecimalFormat("###,##0.00"); 
          }else if(num == 3){
          df = new DecimalFormat("###,##0.000"); 
          }else if(num == 4){
          df = new DecimalFormat("###,##0.0000"); 
          }
          }else{
          df = new DecimalFormat("###,###"); 
          }
          return df.format(arg0);
          }
          }
          posted @ 2015-08-07 13:47 藤本薔薇 閱讀(587) | 評(píng)論 (0)編輯 收藏
          假如  redis  在/usr/local/bin

          配置文件在/usr/local/redis-2.8.21 

           root@iZ239bujfzrZ:    /usr/local/bin# ./redis-server redis.conf nohup 
          posted @ 2015-08-07 10:36 藤本薔薇 閱讀(213) | 評(píng)論 (0)編輯 收藏

                public static interface NUMBER{
          public static String STR_FORMAT = "00000"; 
                  static String TOKEN = null; 
          }


          //配資單號(hào)格式
              public static String AddOne(String code){
             Integer intHao = Integer.parseInt(code);
             intHao++;
             DecimalFormat df = new DecimalFormat(NUMBER.STR_FORMAT);
             return df.format(intHao);
              }
              
              public static void main(String[] args) {
              String code = "ASD0034252345234500001";
                 String  xlh = code.substring(code.length()-5, code.length());
                 System.out.println("數(shù)據(jù)庫原有的最大序列號(hào):"+xlh);
                 if(xlh!=null){
                System.out.println("累加的新生成的序列號(hào):"+AddOne(xlh));
                 }else{
                System.out.println("最新的新生成的序列號(hào):"+"00001"); //如果沒有手動(dòng)生成一條最小的
                 }
            }
              
          posted @ 2015-08-03 11:50 藤本薔薇 閱讀(451) | 評(píng)論 (0)編輯 收藏
              /**
               * 獲取股票板塊信息
               * 滬市A股 : 600、601、603 開頭
               * 深市A股 : 000開頭
               * 中小板 : 002開頭
               * 創(chuàng)業(yè)板 : 300開頭
               * 滬市新股申購:730
               * @param code
               * @return
               */
              public static int getPlateInfo(String code){
              if(code.startsWith("600") || code.startsWith("601") || code.startsWith("603")){
              return 0;
              }else if(code.startsWith("000")){
              return 1;
              }else if(code.startsWith("002")){
              return 2;
              }else if(code.startsWith("300")){
              return 3;
              }else if(code.startsWith("730")){
              return 4;
              }else {
              return 5;
              }
              }
          posted @ 2015-07-29 19:07 藤本薔薇 閱讀(372) | 評(píng)論 (0)編輯 收藏
           
                      我想把String 類型 yyyy-MM-dd 格式的數(shù)據(jù)轉(zhuǎn)換成 String 類型  yyyyMMdd 格式,然后

          String end_date = "2015-09-07";
                  SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd"); 
                  Date date_2 = formatter.parse(end_date);
          String date_22 = formatter.format(date_2);
          System.out.println(date_2);
          System.out.println(date_22);

            
                  打印出來結(jié)果是:
                          Tue Dec 09 00:00:00 CST 2014
                          20141209

                 后來,吾家上神告知,不能直接轉(zhuǎn)
                
                          String end_date = "2015-09-07";
          DateFormat format =new SimpleDateFormat("yyyy-MM-dd");
          Date date_1 = format.parse(end_date);
          format = new SimpleDateFormat("yyyyMMdd");  
          String date_11 = format.format(date_1);
          System.out.println(date_1);
          System.out.println(date_11);


                打印出來結(jié)果是:

                         Mon Sep 07 00:00:00 CST 2015
                         20150907


              總結(jié)語: 吾家上神棒棒噠?。?!

          posted @ 2015-07-27 16:27 藤本薔薇 閱讀(203) | 評(píng)論 (0)編輯 收藏
                   
                       原本寫了 if  else  判斷股票所屬板塊的,覺得繁瑣,就去改了下面的

                            public static void main(String[] args) {
              String code ="002348";
              String stock = "002".equals(code.substring(0,3)) ? "002" : code.substring(0,1);
          System.out.println(stock);
          }

                         然后跑去得瑟,被鄙視了,然后  ↓↓↓↓

                           public static String getPlateInfo(String code){
              return code.startsWith("002") ? "002" : code.substring(0,1);
                            }

                      還補(bǔ)了一刀,你看你寫的什么玩意兒,哼,好想讓他跪搓衣板
          posted @ 2015-07-02 00:26 藤本薔薇 閱讀(231) | 評(píng)論 (0)編輯 收藏
          Map<String, Object> userInfoMap = new HashMap<String, Object>();
          // String data = JsonUtil.toJson(infoMap);
          userInfoMap.put("agent", agent);
          userInfoMap.put("ename", ename);
          Map<String, Object> infoMap = SocketLogic.logic.userInfo(userInfoMap);
          JSONObject rootObj = (JSONObject)JSONObject.toJSON(infoMap);
          JSONArray nodeArr = rootObj.getJSONArray("node");
          for(int i = 0; i < nodeArr.size(); i ++) {
          authority = nodeArr.getJSONObject(i).get("authority").toString();          //交易權(quán)限
          margin = nodeArr.getJSONObject(i).getLongValue("margin");  //保證金
          warn = nodeArr.getJSONObject(i).getFloatValue("warn");      //警戒線
          close = nodeArr.getJSONObject(i).getFloatValue("close");    //平倉線
          end =  nodeArr.getJSONObject(i).getLongValue("end");       //結(jié)束時(shí)間
          mainp = nodeArr.getJSONObject(i).getFloatValue("mainp"); //主板單票比例
          midp = nodeArr.getJSONObject(i).getFloatValue("midp");   //中小板單票比例
          growp = nodeArr.getJSONObject(i).getFloatValue("growp"); //創(chuàng)業(yè)板單票比例
             
          }
          posted @ 2015-06-29 19:20 藤本薔薇 閱讀(334) | 評(píng)論 (1)編輯 收藏
          僅列出標(biāo)題
          共8頁: 上一頁 1 2 3 4 5 6 7 8 下一頁 
          主站蜘蛛池模板: 玉林市| 平昌县| 广水市| 信丰县| 通化县| 沛县| 东安县| 武山县| 昌江| 海兴县| 通道| 错那县| 平昌县| 电白县| 屏南县| 海兴县| 比如县| 丽水市| 江陵县| 台东县| 成武县| 大城县| 比如县| 藁城市| 南川市| 察哈| 太和县| 岑巩县| 东丽区| 如皋市| 舞阳县| 兴安县| 麟游县| 台北县| 手游| 安国市| 中卫市| 西贡区| 楚雄市| 九龙县| 东源县|