首页 文章 精选 留言 我的

精选列表

搜索[字符编码],共10015篇文章
优秀的个人博客,低调大师

JAVA之带转义字符的json字符串解析

Json数据: { "ret":"0", "Weathers":"[{\"date\":\"2017-03-20\",\"weatherType\":\"阴,大部分地区有零星小雨或小雨,上午能见度2-5km转阴天间多云\",\"temperature_min\":\"6\",\"wind_force\":\"微风\",\"temperature_max\":\"12\",\"wind_direction\":\"\"},{\"date\":\"2017-03-21\",\"weatherType\":\"阴转多云\",\"temperature_min\":\"6\",\"wind_force\":\"微风\",\"temperature_max\":\"13\",\"wind_direction\":\"\"},{\"date\":\"2017-03-22\",\"weatherType\":\"多云转阴\",\"temperature_min\":\"6\",\"wind_force\":\"微风\",\"temperature_max\":\"14\",\"wind_direction\":\"\"},{\"date\":\"2017-03-23\",\"weatherType\":\"阴转小雨\",\"temperature_min\":\"3\",\"wind_force\":\"微风\",\"temperature_max\":\"10\",\"wind_direction\":\"\"},{\"date\":\"2017-03-24\",\"weatherType\":\"雨夹雪转多云\",\"temperature_min\":\"0\",\"wind_force\":\"微风\",\"temperature_max\":\"5\",\"wind_direction\":\"\"},{\"date\":\"2017-03-25\",\"weatherType\":\"多云转晴\",\"temperature_min\":\"5\",\"wind_force\":\"微风转3到4级\",\"temperature_max\":\"13\",\"wind_direction\":\"\"},{\"date\":\"2017-03-26\",\"weatherType\":\"晴\",\"temperature_min\":\"4\",\"wind_force\":\"3到4级\",\"temperature_max\":\"14\",\"wind_direction\":\"\"}]" } JSONObjectjsonObject=newJSONObject(result); Stringweathers=jsonObject.getString("Weathers"); JSONArrayweathersArray=newJSONArray(weathers); //直接这样解析会报错 //JSONArrayweathersArray=jsonObject.getJSONArray("weathers"); 转载于:http://blog.csdn.net/panyzyw/article/details/64130020

优秀的个人博客,低调大师

Java 字符串 之 字符串 记事本实例

http://www.verejava.com/?id=17159658585531 import java.util.Scanner; public class Test { private Scanner in; private StringBuffer sb = new StringBuffer(); private boolean flag = true; private String clipBoard;//剪贴板 public Test() { in = new Scanner(System.in); System.out.println("1 : 键盘输入编辑文字"); System.out.println("2 : 追加文字"); System.out.println("3 : 插入文字 (索引号:要插入的文字)"); System.out.println("4 : 替换文字 (要替换的文字:新文字)"); System.out.println("5 : 查找文字(返回找到的文字的索引号)"); System.out.println("6 : 删除文字(开始索引号:结束索引号)"); System.out.println("7 : 复制文字 (开始索引号:结束索引号)"); System.out.println("8 : 粘贴文字(索引号)"); System.out.println("9 : 剪切文字(开始索引号:结束索引号)"); System.out.println("10 : 转换成大写"); System.out.println("11 : 转换成小写"); System.out.println("12 : 文字反转"); System.out.println("-1 : 退出编辑"); while (flag) { String key = in.nextLine(); if ("1".equals(key)) { input(); } if ("-1".equals(key)) { exit(); } if ("2".equals(key)) { append(); } if ("3".equals(key)) { insert(); } if ("4".equals(key)) { replace(); } if ("5".equals(key)) { search(); } if ("6".equals(key)) { delete(); } if ("7".equals(key)) { copy(); } if ("8".equals(key)) { paste(); } if ("9".equals(key)) { cut(); } if ("10".equals(key)) { toUpperCase(); } if ("11".equals(key)) { toLowerCase(); } if ("12".equals(key)) { rerverse(); } System.out.println("记事本当前文本:" + sb.toString()); } } private void rerverse() { sb.reverse(); } private void toLowerCase() { String buffer = sb.toString(); buffer = buffer.toLowerCase(); sb.delete(0, sb.length()); sb.append(buffer); } private void toUpperCase() { String buffer = sb.toString(); buffer = buffer.toUpperCase(); sb.delete(0, sb.length()); sb.append(buffer); } private void cut() { System.out.println("请输入要剪切文字(开始索引号:结束索引号)"); String text = in.nextLine(); String[] texts = text.split(":"); int startIndex = Integer.parseInt(texts[0]); int endIndex = Integer.parseInt(texts[1]); clipBoard = sb.substring(startIndex, endIndex); //删除记事本文字 sb.delete(startIndex, endIndex); } private void paste() { System.out.println("请输入要粘贴文字(索引号)"); String text = in.nextLine(); int index = Integer.parseInt(text); //粘贴 sb.insert(index, clipBoard); } private void copy() { System.out.println("请输入要复制文字 (开始索引号:结束索引号)"); String text = in.nextLine(); String[] texts = text.split(":"); int startIndex = Integer.parseInt(texts[0]); int endIndex = Integer.parseInt(texts[1]); clipBoard = sb.substring(startIndex, endIndex); } private void delete() { System.out.println("请输入要删除文字(开始索引号:结束索引号)"); String text = in.nextLine(); String[] texts = text.split(":"); int startIndex = Integer.parseInt(texts[0]); int endIndex = Integer.parseInt(texts[1]); //删除 sb.delete(startIndex, endIndex); } private void search() { System.out.println("请输入要查找文字(返回找到的文字的索引号)"); String text = in.nextLine(); int index = sb.indexOf(text); if (index >= 0) { System.out.println(text + " 索引号:" + index); } else { System.out.println(text + " 不存在"); } } private void replace() { System.out.println("请输入要替换文字 (要替换的文字:新文字)"); String text = in.nextLine(); String[] texts = text.split(":"); String oldText = texts[0]; String newText = texts[1]; //替换 String buffer = sb.toString(); buffer = buffer.replace(oldText, newText); sb.delete(0, sb.length());//清空记事本文字 sb.append(buffer); } private void insert() { System.out.println("请输入要插入的文字: (索引号:要插入的文字)"); String text = in.nextLine(); String[] texts = text.split(":"); int index = Integer.parseInt(texts[0]); String str = texts[1]; //插入文字 sb.insert(index, str); } private void append() { System.out.println("请输入要追加文字:"); String text = in.nextLine(); //追加文字 sb.append(text); } private void exit() { flag = false; System.exit(0);//退出应用程序 } private void input() { System.out.println("请输入要编辑的文字:"); String text = in.nextLine(); //添加到 sb 记事本的缓冲区 sb.append(text); } public static void main(String[] args) { new Test(); } } http://www.verejava.com/?id=17159658585531

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册