📄 weather.java
字号:
return "阵雨"; else if (strData.equals("04")) return "雷阵雨"; else if (strData.equals("05")) return "雷阵雨并伴有冰雹"; else if (strData.equals("06")) return "雨加雪"; else if (strData.equals("07")) return "小雨"; else if (strData.equals("08")) return "中雨"; else if (strData.equals("09")) return "大雨"; else if (strData.equals("10")) return "暴雨"; else if (strData.equals("11")) return "大暴雨"; else if (strData.equals("12")) return "特大暴雨"; else if (strData.equals("13")) return "阵雪"; else if (strData.equals("14")) return "小雪"; else if (strData.equals("15")) return "中雪"; else if (strData.equals("16")) return "大雪"; else if (strData.equals("17")) return "暴雪"; else if (strData.equals("18")) return "雾"; else if (strData.equals("19")) return "冻雨"; else if (strData.equals("20")) return "沙尘暴"; else if (strData.equals("21")) return "小雨转中雨"; else if (strData.equals("22")) return "中雨转大雨"; else if (strData.equals("23")) return "大雨转暴雨"; else if (strData.equals("24")) return "暴雨转大暴雨"; else if (strData.equals("25")) return "大暴雨转特大暴雨"; else if (strData.equals("26")) return "小雪转中雪"; else if (strData.equals("27")) return "中雪转大雪"; else if (strData.equals("28")) return "大雪转暴雪"; else if (strData.equals("29")) return "浮尘"; else if (strData.equals("30")) return "扬沙"; else if (strData.equals("31")) return "强沙尘暴"; return "未知天气情况";}public String WindWay(String str){ if (str.equals("0")) return "无风"; if (str.equals("1")) return "东北风"; if (str.equals("2")) return "东风"; if (str.equals("3")) return "东南风"; if (str.equals("4")) return "南风"; if (str.equals("5")) return "西南风"; if (str.equals("6")) return "西风"; if (str.equals("7")) return "西北风"; if (str.equals("8")) return "北风"; if (str.equals("9")) return "旋转,不定"; return "未知风向";}public String WindPower(String str){ //str.TrimLeft(str); if (str.equals("0")) return "小于3"; //return "0"; if (str.equals("1")) return "3~4"; //return "1"; if (str.equals("2")) return "4~5"; //return "2"; if (str.equals("3")) return "5~6"; //return "3"; if (str.equals("4")) return "6~7"; //return "4"; if (str.equals("5")) return "7~8"; //return "5"; if (str.equals("6")) return "8~9"; //return "6"; if (str.equals("7")) return "9~10"; //return "7"; if (str.equals("8")) return "10~11"; //return "8"; if (str.equals("9")) return "11~12"; //return "9"; return "未知风力";}public String decodeTemp(String code){ String result ="未知温度"; System.out.println("t"+code); if(code.length() ==5){ code = code.substring(1,code.length() ); } String t_b = code.substring(0,2); String t_e = code.substring(2,4) ; int t_bI = 0,t_eI = 0; if(Integer.parseInt(t_b)>=50 ){ t_bI = 50 - Integer.parseInt(t_b); }else{ t_bI = Integer.parseInt(t_b); } if(Integer.parseInt(t_e)>=50 ){ t_eI = 50 - Integer.parseInt(t_e); }else{ t_eI = Integer.parseInt(t_e); } result = String.valueOf(t_bI)+"℃-"+String.valueOf(t_eI)+"℃"; return result ;}public String decodeWeather(String code){ String result = "未知天气"; System.out.println("wea"+code); if(code.length() ==5){ code = code.substring(1,code.length() ); } System.out.println(code); String w_b = code.substring(0,2); String w_e = code.substring(2,4) ; System.out.println(w_b+":"+w_e); result = Phenomena(w_b)+"-"+Phenomena(w_e); return result;}public String decodeWind(String code){ String result = "未知风力风向"; System.out.println("w"+code); if(code.length() ==5){ code = code.substring(1,code.length() ); } String f_x_b = code.substring(0,1); System.out.println(f_x_b); String f_l_b = code.substring(1,2) ; System.out.println(f_l_b); String f_x_e = code.substring(2,3); System.out.println(f_x_e); String f_l_e = code.substring(3,4) ; System.out.println(f_l_e); result = WindWay(f_x_b)+WindPower(f_l_b)+"-"+WindWay(f_x_e)+WindPower(f_l_e); return result;}public Vector findCity(String province ,String path){ File f = new File("f.txt"); try{ f.createNewFile() ; }catch(Exception e){} Vector resultV = new Vector(); for(int i = 24;i>=0;i--){ String hh = ""; if(i<10){ hh = "0"+String.valueOf(i); }else{ hh = String.valueOf(i); } File file = new File(path+"forecast"+Utility.getFileDateString()+hh+".txt"); System.out.println(path+"forecast"+Utility.getFileDateString()+hh+".txt"); if(file.exists() && file.length() >0 ){ System.out.println("find file"); try{ BufferedReader br = new BufferedReader((new FileReader(file))); String line = ""; while(!(line = new String((br.readLine()).getBytes() ,"gb2312") ).equals("") ){ if(line.indexOf(province) != -1){ System.out.println(line); StringTokenizer st = new StringTokenizer(line,","); if(st.hasMoreElements()){ st.nextElement(); } if(st.hasMoreElements()){ resultV.addElement(st.nextElement()); } } } br.close() ; }catch(Exception e){ //e.printStackTrace() ; } }else{ file = new File(path+"forecast"+Utility.getPreFileDateString()+hh+".txt"); System.out.println("findiing"); try{ BufferedReader br = new BufferedReader((new FileReader(file))); String line = ""; while(!(line = new String((br.readLine()).getBytes() ,"gb2312") ).equals("") ){ if(line.indexOf(province) != -1){ System.out.println(line); StringTokenizer st = new StringTokenizer(line,","); if(st.hasMoreElements()){ st.nextElement(); } if(st.hasMoreElements()){ resultV.addElement(st.nextElement()); } } } br.close() ; }catch(Exception e){ //e.printStackTrace() ; } } } System.out.println(resultV); return resultV;} public static void main(String[] args) { Weather weather1 = new Weather(); System.out.println(weather1.GetAll("三河","D:\\JRun4\\servers\\default\\default-ear\\default-war\\test\\WAPServer\\jsp\\db\\") ); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -