set:

ResultPo resultPo=new ResultPo();

 for(int j=6;j<st1.length;j++){//映射存储96时段
                          String setAttributeMethodName = "setH"+(j<10?"0"+j:j);
                            Method setAttributeMethod = null;
                          try {
                              setAttributeMethod = ResultPo.class.getDeclaredMethod(setAttributeMethodName);
                              try {
                                  setAttributeMethod.invoke(resultPo,st1[j]);
                              } catch (IllegalAccessException e) {
                                  e.printStackTrace();
                              } catch (IllegalArgumentException e) {
                                  e.printStackTrace();
                              } catch (InvocationTargetException e) {
                                  e.printStackTrace();
                              }
                          } catch (NoSuchMethodException e) {
                              e.printStackTrace();
                          } catch (SecurityException e) {
                              e.printStackTrace();
                          }
                          
                      }

 

get:

TypePo obj=typeList.get(i);
            for(int j=1;j<=96;j++){
                String getAttributeMethodName = "getH"+(j<10?"0"+j:j);
                Method getAttributeMethod = null;
                try {
                    getAttributeMethod = TypePo.class.getDeclaredMethod(getAttributeMethodName);
                    try {
                        String corhr = (String) getAttributeMethod.invoke(obj);
                        content=content+"#    "+typnum+"    "+j+"    "+corhr+"    valley"+"\r\n";
                        typnum++;
                    } catch (IllegalAccessException e) {
                        e.printStackTrace();
                    } catch (IllegalArgumentException e) {
                        e.printStackTrace();
                    } catch (InvocationTargetException e) {
                        e.printStackTrace();
                    }
                } catch (NoSuchMethodException e) {
                    e.printStackTrace();
                } catch (SecurityException e) {
                    e.printStackTrace();
                }
                
            }     

相关文章:

  • 2021-10-25
  • 2021-07-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-06
  • 2022-12-23
猜你喜欢
  • 2021-09-09
  • 2022-12-23
  • 2021-09-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-07
相关资源
相似解决方案