Java发送post请求 1.省份字典 2.姓氏字典 3.结婚时祝愿字典 4.发送Post请求 5.整合一起
1.省份字典
List < String > provinces = new ArrayList < > ( ) ; provinces. add ( "北京" ) ; provinces. add ( "天津" ) ; provinces. add ( "河北" ) ; provinces. add ( "山西" ) ; provinces. add ( "内蒙古" ) ; provinces. add ( "辽宁" ) ; provinces. add ( "吉林" ) ; provinces. add ( "黑龙江" ) ; provinces. add ( "上海" ) ; provinces. add ( "江苏" ) ; provinces. add ( "浙江" ) ; provinces. add ( "安徽" ) ; provinces. add ( "福建" ) ; provinces. add ( "江西" ) ; provinces. add ( "山东" ) ; provinces. add ( "河南" ) ; provinces. add ( "湖北" ) ; provinces. add ( "湖南" ) ; provinces. add ( "广东" ) ; provinces. add ( "广西" ) ; provinces. add ( "海南" ) ; provinces. add ( "重庆" ) ; provinces. add ( "四川" ) ; provinces. add ( "贵州" ) ; provinces. add ( "云南" ) ; provinces. add ( "西藏" ) ; provinces. add ( "陕西" ) ; provinces. add ( "甘肃" ) ; provinces. add ( "青海" ) ; provinces. add ( "宁夏" ) ; provinces. add ( "新疆" ) ;
2.姓氏字典
List < String > surnames = new ArrayList < > ( ) ; surnames. add ( "王" ) ; surnames. add ( "李" ) ; surnames. add ( "张" ) ; surnames. add ( "刘" ) ; surnames. add ( "陈" ) ; surnames. add ( "杨" ) ; surnames. add ( "赵" ) ; surnames. add ( "黄" ) ; surnames. add ( "周" ) ; surnames. add ( "吴" ) ; surnames. add ( "徐" ) ; surnames. add ( "孙" ) ; surnames. add ( "胡" ) ; surnames. add ( "朱" ) ; surnames. add ( "高" ) ; surnames. add ( "林" ) ; surnames. add ( "何" ) ; surnames. add ( "郭" ) ; surnames. add ( "马" ) ; surnames. add ( "罗" ) ; surnames. add ( "梁" ) ; surnames. add ( "宋" ) ; surnames. add ( "郑" ) ; surnames. add ( "谢" ) ; surnames. add ( "韩" ) ; surnames. add ( "唐" ) ; surnames. add ( "冯" ) ; surnames. add ( "于" ) ; surnames. add ( "董" ) ; surnames. add ( "萧" ) ; surnames. add ( "程" ) ; surnames. add ( "曹" ) ; surnames. add ( "袁" ) ; surnames. add ( "邓" ) ; surnames. add ( "许" ) ; surnames. add ( "傅" ) ; surnames. add ( "沈" ) ; surnames. add ( "曾" ) ; surnames. add ( "彭" ) ; surnames. add ( "刘" ) ; surnames. add ( "蔡" ) ; surnames. add ( "潘" ) ; surnames. add ( "蒋" ) ; surnames. add ( "魏" ) ; surnames. add ( "丁" ) ; surnames. add ( "余" ) ; surnames. add ( "苏" ) ; surnames. add ( "侯" ) ; surnames. add ( "金" ) ; surnames. add ( "贾" ) ;
3.结婚时祝愿字典
Set < String > wishes = new HashSet < > ( ) ; wishes. add ( "百年好合,永结同心,白头偕老,恩爱两不疑。" ) ; wishes. add ( "珠联璧合,鸾凤和鸣,琴瑟和鸣,花好月圆。" ) ; wishes. add ( "比翼双飞,早生贵子,阖家欢乐,幸福美满。" ) ; wishes. add ( "同甘共苦,有福同享,有難同當,一生一世一双人。" ) ; wishes. add ( "白首不相离,举案齐眉,相敬如宾,夫唱妇随。" ) ; wishes. add ( "天作之合,地久天长,海枯石烂,永不分离。" ) ; wishes. add ( "郎才女貌,天赐良缘,珠联璧合,天作之合。" ) ; wishes. add ( "花好月圆,琴瑟和鸣,举案齐眉,白头偕老。" ) ; wishes. add ( "比翼双飞,恩爱两不疑,同甘共苦,有福同享。" ) ; wishes. add ( "一生一世一双人,白首不相离,幸福美满,早生贵子。" ) ; wishes. add ( "鸾凤和鸣,琴瑟和鸣,举案齐眉,相敬如宾。" ) ; wishes. add ( "天作之合,地久天长,海枯石烂,永不分离。" ) ; wishes. add ( "郎才女貌,天赐良缘,珠联璧合,天作之合。" ) ; wishes. add ( "花好月圆,琴瑟和鸣,举案齐眉,白头偕老。" ) ; wishes. add ( "比翼双飞,恩爱两不疑,同甘共苦,有福同享。" ) ; wishes. add ( "一生一世一双人,白首不相离,幸福美满,早生贵子。" ) ; wishes. add ( "愿你们恩爱白头偕老,琴瑟和鸣永不休。" ) ; wishes. add ( "花好月圆人团圆,鸾凤和鸣喜相逢。" ) ; wishes. add ( "比翼双飞共白首,同甘共苦永相随。" ) ; wishes. add ( "天作之合情投意合,地久天长心相印。" ) ; wishes. add ( "郎才女貌天作之合,珠联璧合幸福美满。" ) ; wishes. add ( "花开并蒂连理枝,福禄双全永结缘。" ) ; wishes. add ( "比肩携手,共度人生,恩爱白头,幸福绵长。" ) ; wishes. add ( "福禄双全,喜气洋洋,琴瑟和鸣,白头偕老。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; List < String > res = new ArrayList < > ( wishes) ;
4.发送Post请求
URL obj = new URL ( url) ; for ( int i = 0 ; i < maxLength ; i++ ) { name = provinces. get ( i) + "省" + surnames. get ( i) ; if ( i % 2 == 0 ) { name = name + "小姐" ; } else { name = name + "先生" ; } String s = "--" + res. get ( i) ; String postData = "{\"cardId\":\"" + cardId + "\",\"name\":\"" + name + "\",\"openId\":\"" + openId + "\",\"wishLanguage\":\"" + s + "\"}" ; HttpURLConnection conn = ( HttpURLConnection ) obj. openConnection ( ) ; conn. setRequestMethod ( "POST" ) ; conn. setRequestProperty ( "Content-Type" , "application/json" ) ; conn. setDoOutput ( true ) ; DataOutputStream wr = new DataOutputStream ( conn. getOutputStream ( ) ) ; wr. write ( postData. getBytes ( StandardCharsets . UTF_8) ) ; wr. flush ( ) ; wr. close ( ) ; conn. getResponseCode ( ) ; conn. disconnect ( ) ;
5.整合一起
@Test public void wish ( ) throws IOException { String url = "" ; Set < String > wishes = new HashSet < > ( ) ; wishes. add ( "百年好合,永结同心,白头偕老,恩爱两不疑。" ) ; wishes. add ( "珠联璧合,鸾凤和鸣,琴瑟和鸣,花好月圆。" ) ; wishes. add ( "比翼双飞,早生贵子,阖家欢乐,幸福美满。" ) ; wishes. add ( "同甘共苦,有福同享,有難同當,一生一世一双人。" ) ; wishes. add ( "白首不相离,举案齐眉,相敬如宾,夫唱妇随。" ) ; wishes. add ( "天作之合,地久天长,海枯石烂,永不分离。" ) ; wishes. add ( "郎才女貌,天赐良缘,珠联璧合,天作之合。" ) ; wishes. add ( "花好月圆,琴瑟和鸣,举案齐眉,白头偕老。" ) ; wishes. add ( "比翼双飞,恩爱两不疑,同甘共苦,有福同享。" ) ; wishes. add ( "一生一世一双人,白首不相离,幸福美满,早生贵子。" ) ; wishes. add ( "鸾凤和鸣,琴瑟和鸣,举案齐眉,相敬如宾。" ) ; wishes. add ( "天作之合,地久天长,海枯石烂,永不分离。" ) ; wishes. add ( "郎才女貌,天赐良缘,珠联璧合,天作之合。" ) ; wishes. add ( "花好月圆,琴瑟和鸣,举案齐眉,白头偕老。" ) ; wishes. add ( "比翼双飞,恩爱两不疑,同甘共苦,有福同享。" ) ; wishes. add ( "一生一世一双人,白首不相离,幸福美满,早生贵子。" ) ; wishes. add ( "愿你们恩爱白头偕老,琴瑟和鸣永不休。" ) ; wishes. add ( "花好月圆人团圆,鸾凤和鸣喜相逢。" ) ; wishes. add ( "比翼双飞共白首,同甘共苦永相随。" ) ; wishes. add ( "天作之合情投意合,地久天长心相印。" ) ; wishes. add ( "郎才女貌天作之合,珠联璧合幸福美满。" ) ; wishes. add ( "花开并蒂连理枝,福禄双全永结缘。" ) ; wishes. add ( "比肩携手,共度人生,恩爱白头,幸福绵长。" ) ; wishes. add ( "福禄双全,喜气洋洋,琴瑟和鸣,白头偕老。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; wishes. add ( "同心同德,白头偕老,永结同心,百年好合。" ) ; wishes. add ( "天作之合,地久天长,鸾凤和鸣,琴瑟和鸣。" ) ; wishes. add ( "花好月圆,人寿年丰,美满幸福,万事如意。" ) ; wishes. add ( "花开富贵,福满堂,夫妻恩爱,幸福长。" ) ; List < String > res = new ArrayList < > ( wishes) ; List < String > surnames = new ArrayList < > ( ) ; surnames. add ( "王" ) ; surnames. add ( "李" ) ; surnames. add ( "张" ) ; surnames. add ( "刘" ) ; surnames. add ( "陈" ) ; surnames. add ( "杨" ) ; surnames. add ( "赵" ) ; surnames. add ( "黄" ) ; surnames. add ( "周" ) ; surnames. add ( "吴" ) ; surnames. add ( "徐" ) ; surnames. add ( "孙" ) ; surnames. add ( "胡" ) ; surnames. add ( "朱" ) ; surnames. add ( "高" ) ; surnames. add ( "林" ) ; surnames. add ( "何" ) ; surnames. add ( "郭" ) ; surnames. add ( "马" ) ; surnames. add ( "罗" ) ; surnames. add ( "梁" ) ; surnames. add ( "宋" ) ; surnames. add ( "郑" ) ; surnames. add ( "谢" ) ; surnames. add ( "韩" ) ; surnames. add ( "唐" ) ; surnames. add ( "冯" ) ; surnames. add ( "于" ) ; surnames. add ( "董" ) ; surnames. add ( "萧" ) ; surnames. add ( "程" ) ; surnames. add ( "曹" ) ; surnames. add ( "袁" ) ; surnames. add ( "邓" ) ; surnames. add ( "许" ) ; surnames. add ( "傅" ) ; surnames. add ( "沈" ) ; surnames. add ( "曾" ) ; surnames. add ( "彭" ) ; surnames. add ( "刘" ) ; surnames. add ( "蔡" ) ; surnames. add ( "潘" ) ; surnames. add ( "蒋" ) ; surnames. add ( "魏" ) ; surnames. add ( "丁" ) ; surnames. add ( "余" ) ; surnames. add ( "苏" ) ; surnames. add ( "侯" ) ; surnames. add ( "金" ) ; surnames. add ( "贾" ) ; List < String > provinces = new ArrayList < > ( ) ; provinces. add ( "北京" ) ; provinces. add ( "天津" ) ; provinces. add ( "河北" ) ; provinces. add ( "山西" ) ; provinces. add ( "内蒙古" ) ; provinces. add ( "辽宁" ) ; provinces. add ( "吉林" ) ; provinces. add ( "黑龙江" ) ; provinces. add ( "上海" ) ; provinces. add ( "江苏" ) ; provinces. add ( "浙江" ) ; provinces. add ( "安徽" ) ; provinces. add ( "福建" ) ; provinces. add ( "江西" ) ; provinces. add ( "山东" ) ; provinces. add ( "河南" ) ; provinces. add ( "湖北" ) ; provinces. add ( "湖南" ) ; provinces. add ( "广东" ) ; provinces. add ( "广西" ) ; provinces. add ( "海南" ) ; provinces. add ( "重庆" ) ; provinces. add ( "四川" ) ; provinces. add ( "贵州" ) ; provinces. add ( "云南" ) ; provinces. add ( "西藏" ) ; provinces. add ( "陕西" ) ; provinces. add ( "甘肃" ) ; provinces. add ( "青海" ) ; provinces. add ( "宁夏" ) ; provinces. add ( "新疆" ) ; int maxLength = Math . min ( res. size ( ) , provinces. size ( ) ) ; String cardId = "" ; String name = "高中女神" ; String openId = "" ; String wishLanguage = "每一天" ; URL obj = new URL ( url) ; for ( int i = 0 ; i < maxLength ; i++ ) { name = provinces. get ( i) + "省" + surnames. get ( i) ; if ( i % 2 == 0 ) { name = name + "小姐" ; } else { name = name + "先生" ; } String s = "--" + res. get ( i) ; String postData = "{\"cardId\":\"" + cardId + "\",\"name\":\"" + name + "\",\"openId\":\"" + openId + "\",\"wishLanguage\":\"" + s + "\"}" ; HttpURLConnection conn = ( HttpURLConnection ) obj. openConnection ( ) ; conn. setRequestMethod ( "POST" ) ; conn. setRequestProperty ( "Content-Type" , "application/json" ) ; conn. setDoOutput ( true ) ; DataOutputStream wr = new DataOutputStream ( conn. getOutputStream ( ) ) ; wr. write ( postData. getBytes ( StandardCharsets . UTF_8) ) ; wr. flush ( ) ; wr. close ( ) ; conn. getResponseCode ( ) ; conn. disconnect ( ) ; } }