首页 文章 精选 留言 我的

精选列表

搜索[android studio],共10000篇文章
优秀的个人博客,低调大师

腾讯Android自动化测试实战导读

前 言 Preface 为什么要写这本书 早在2010年年底,我们团队就有出一本关于移动互联网测试书籍的计划(那时候移动互联网测试书籍基本没有),当时计划的内容涉及面比较广,涵盖测试设计、测试用例管理、测试流程、自动化测试、专项测试等领域。不过,由于各种原因被搁浅,确实有点儿可惜,否则移动互联网测试国内的第一本书当时就面世了。这次终于又有机会整理这些年的测试经验并形成一本书了,借此可以跟业界的同行一起交流切磋。 TMQ(Tencent Mobile Quality)腾讯移动品质中心,是腾讯内部最早专注于移动App测试的团队,在10余年的时间内承担了近10款业界领先产品的测试工作,为腾讯向移动方向转型提供了多项质量方案和关键专利。本书的作者都是TMQ平台的核心成员,服务于公司级的手机QQ浏览器、应用宝等项目,经过这几年在移动测试领域的探

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

Android--List转换String,String转换List

版权声明:本文为博主原创文章,转载请标明出处。 https://blog.csdn.net/chaoyu168/article/details/68927553 调用方法: //字符串转成list List list; String im = "123+456+789"; list = StringToList(im); //list转字符串 String str = ListToString("要转换的List"); 封装的类: private static final String SEP1 = "#"; private static final String SEP2 = "|"; private static final String SEP3 = "="; /** * List转换String * * @param list * :需要转换的List * @return String转换后的字符串 */ public static String ListToString(List<?> list) { StringBuffer sb = new StringBuffer(); if (list != null && list.size() > 0) { for (int i = 0; i < list.size(); i++) { if (list.get(i) == null || list.get(i) == "") { continue; } // 如果值是list类型则调用自己 if (list.get(i) instanceof List) { sb.append(ListToString((List<?>) list.get(i))); sb.append(SEP1); } else if (list.get(i) instanceof Map) { sb.append(MapToString((Map<?, ?>) list.get(i))); sb.append(SEP1); } else { sb.append(list.get(i)); sb.append(SEP1); } } } return "L" + sb.toString(); } /** * Map转换String * * @param map * :需要转换的Map * @return String转换后的字符串 */ public static String MapToString(Map<?, ?> map) { StringBuffer sb = new StringBuffer(); // 遍历map for (Object obj : map.keySet()) { if (obj == null) { continue; } Object key = obj; Object value = map.get(key); if (value instanceof List<?>) { sb.append(key.toString() + SEP1 + ListToString((List<?>) value)); sb.append(SEP2); } else if (value instanceof Map<?, ?>) { sb.append(key.toString() + SEP1 + MapToString((Map<?, ?>) value)); sb.append(SEP2); } else { sb.append(key.toString() + SEP3 + value.toString()); sb.append(SEP2); } } return "M" + sb.toString(); } /** * String转换Map * * @param mapText * :需要转换的字符串 * @param KeySeparator * :字符串中的分隔符每一个key与value中的分割 * @param ElementSeparator * :字符串中每个元素的分割 * @return Map<?,?> */ public static Map<String, Object> StringToMap(String mapText) { if (mapText == null || mapText.equals("")) { return null; } mapText = mapText.substring(1); mapText = mapText; Map<String, Object> map = new HashMap<String, Object>(); String[] text = mapText.split("\\" + SEP2); // 转换为数组 for (String str : text) { String[] keyText = str.split(SEP3); // 转换key与value的数组 if (keyText.length < 1) { continue; } String key = keyText[0]; // key String value = keyText[1]; // value if (value.charAt(0) == 'M') { Map<?, ?> map1 = StringToMap(value); map.put(key, map1); } else if (value.charAt(0) == 'L') { List<?> list = StringToList(value); map.put(key, list); } else { map.put(key, value); } } return map; } /** * String转换List * * @param listText * :需要转换的文本 * @return List<?> */ public static List<Object> StringToList(String listText) { if (listText == null || listText.equals("")) { return null; } listText = listText.substring(1); listText = listText; List<Object> list = new ArrayList<Object>(); String[] text = listText.split(SEP1); for (String str : text) { if (str.charAt(0) == 'M') { Map<?, ?> map = StringToMap(str); list.add(map); } else if (str.charAt(0) == 'L') { List<?> lists = StringToList(str); list.add(lists); } else { list.add(str); } } return list; } 利用Java自身类: String abc = "aaa,bbb,ccc"; String[] arr = abc.split(","); List<String> list = java.util.Arrays.aslist(abc);

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

Android--文件夹压缩为.zip

版权声明:本文为博主原创文章,转载请标明出处。 https://blog.csdn.net/chaoyu168/article/details/64439638 package com.zipUtil; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.Enumeration; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import java.util.zip.ZipOutputStream; public class ZipUtil { public static void zip(String src, String dest) throws IOException { //提供了一个数据项压缩成一个ZIP归档输出流 ZipOutputStream out = null; try { File outFile = new File(dest);//源文件或者目录 File fileOrDirectory = new File(src);//压缩文件路径 out = new ZipOutputStream(new FileOutputStream(outFile)); //如果此文件是一个文件,否则为false。 if (fileOrDirectory.isFile()) { zipFileOrDirectory(out, fileOrDirectory, ""); } else { //返回一个文件或空阵列。 File[] entries = fileOrDirectory.listFiles(); for (int i = 0; i < entries.length; i++) { // 递归压缩,更新curPaths zipFileOrDirectory(out, entries[i], ""); } } } catch (IOException ex) { ex.printStackTrace(); } finally { //关闭输出流 if (out != null) { try { out.close(); } catch (IOException ex) { ex.printStackTrace(); } } } } private static void zipFileOrDirectory(ZipOutputStream out, File fileOrDirectory, String curPath) throws IOException { //从文件中读取字节的输入流 FileInputStream in = null; try { //如果此文件是一个目录,否则返回false。 if (!fileOrDirectory.isDirectory()) { // 压缩文件 byte[] buffer = new byte[4096]; int bytes_read; in = new FileInputStream(fileOrDirectory); //实例代表一个条目内的ZIP归档 ZipEntry entry = new ZipEntry(curPath + fileOrDirectory.getName()); //条目的信息写入底层流 out.putNextEntry(entry); while ((bytes_read = in.read(buffer)) != -1) { out.write(buffer, 0, bytes_read); } out.closeEntry(); } else { // 压缩目录 File[] entries = fileOrDirectory.listFiles(); for (int i = 0; i < entries.length; i++) { // 递归压缩,更新curPaths zipFileOrDirectory(out, entries[i], curPath + fileOrDirectory.getName() + "/"); } } } catch (IOException ex) { ex.printStackTrace(); // throw ex; } finally { if (in != null) { try { in.close(); } catch (IOException ex) { ex.printStackTrace(); } } } } @SuppressWarnings("unchecked") public static void unzip(String zipFileName, String outputDirectory) throws IOException { ZipFile zipFile = null; try { zipFile = new ZipFile(zipFileName); Enumeration e = zipFile.entries(); ZipEntry zipEntry = null; File dest = new File(outputDirectory); dest.mkdirs(); while (e.hasMoreElements()) { zipEntry = (ZipEntry) e.nextElement(); String entryName = zipEntry.getName(); InputStream in = null; FileOutputStream out = null; try { if (zipEntry.isDirectory()) { String name = zipEntry.getName(); name = name.substring(0, name.length() - 1); File f = new File(outputDirectory + File.separator + name); f.mkdirs(); } else { int index = entryName.lastIndexOf("\\"); if (index != -1) { File df = new File(outputDirectory + File.separator + entryName.substring(0, index)); df.mkdirs(); } index = entryName.lastIndexOf("/"); if (index != -1) { File df = new File(outputDirectory + File.separator + entryName.substring(0, index)); df.mkdirs(); } File f = new File(outputDirectory + File.separator + zipEntry.getName()); // f.createNewFile(); in = zipFile.getInputStream(zipEntry); out = new FileOutputStream(f); int c; byte[] by = new byte[1024]; while ((c = in.read(by)) != -1) { out.write(by, 0, c); } out.flush(); } } catch (IOException ex) { ex.printStackTrace(); throw new IOException("解压失败:" + ex.toString()); } finally { if (in != null) { try { in.close(); } catch (IOException ex) { } } if (out != null) { try { out.close(); } catch (IOException ex) { } } } } } catch (IOException ex) { ex.printStackTrace(); throw new IOException("解压失败:" + ex.toString()); } finally { if (zipFile != null) { try { zipFile.close(); } catch (IOException ex) { } } } } } 调用: public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Thread th = new Thread(new Runnable() { @Override public void run() { // TODO Auto-generated method stub try { ZipUtil.zip(Environment.getExternalStorageDirectory().getPath()+"/baidu", Environment.getExternalStorageDirectory().getPath()+"/baidu.zip"); ZipUtil.unzip(Environment.getExternalStorageDirectory().getPath()+"/baidu.zip", Environment.getExternalStorageDirectory().getPath()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } });th.start(); }

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

Mario

Mario

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

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

用户登录
用户注册
修改密码
忘记密码