strings. xml 文件中存在什么代码
strings.xml会存在字符串拼接,转意符,xliff字符串替换,国际化处理等代码。
例子如下:
当前语言判断
通过字符串直接判断本机使用语言eg:<string name="language_abbr">EN</string> <string name="language_abbr">PL</string> switch(getString(R.string.language_abbr)){ case "EN": break; case "PL": break; default: break; }
jacksonxml使用方法
public class Demo1 {
public static void main(String[] args) {
XmlMapper xmlMapper = new XmlMapper();
//字段为null,自动忽略,不再序列化
xmlMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
Department department = new Department();
Employees employees1 = new Employees("秋一叶",18,"男");
Employees employees2 = new Employees("小王",20,"男");
department.setDepName("产品研发部门");
department.setEmployees(Lists.newArrayList(employees1, employees2));
try {
//对象转xml
String xml = xmlMapper.writeValueAsString(department);
//xml转对象
Department dep = xmlMapper.readValue(xml, Department.class);
System.out.println("返回的xml:" + xml);
System.out.println("返回的实体:" + dep);
} catch (JsonProcessingException e) {
e.printStackTrace();
还没有评论,来说两句吧...