cocos2d动画工具:-hd.plist生成plist
直接上代码:
[java] /**
* Java 正则表达式驱动,用这种,独立于网络~
* @param input 旧数据读入文件
* @param output 新数据写出文件
*/
public static void divideLogic(File input, File output) {
String raw = StringFileBridge.file2String(input, "UTF-8");
Pattern pattern = Pattern.compile("\\{\\s*\\d+\\s*,\\s{0,}\\d+\\s{0,}\\}");
Matcher matcher = pattern.matcher(raw);
StringBuffer sb = new StringBuffer();
while (matcher.find()) {
String trimed = matcher.group().replaceAll("[\\s*|\\{|\\}]", "");
String[] strs = trimed.split(",");
String s1, s2, handledItem;
s1 = String.valueOf(Integer.parseInt(strs[0]) / 2);
s2 = String.valueOf(Integer.parseInt(strs[1]) / 2);
handledItem = "{" + s1 + "," + s2 + "}";
matcher.appendReplacement(sb, handledItem);
}
matcher.appendTail(sb);
StringFileBridge.string2File(sb.toString(), output);
}
/**
* Java 正则表达式驱动,用这种,独立于网络~
* @param input 旧数据读入文件
* @param output 新数据写出文件
*/
public static void divideLogic(File input, File output) {
String raw = StringFileBridge.file2String(input, "UTF-8");
Pattern pattern = Pattern.compile("\\{\\s*\\d+\\s*,\\s{0,}\\d+\\s{0,}\\}");
Matcher matcher = pattern.matcher(raw);
StringBuffer sb = new StringBuffer();
while (matcher.find()) {
String trimed = matcher.group().replaceAll("[\\s*|\\{|\\}]", "");
String[] strs = trimed.split(",");
String s1, s2, handledItem;
s1 = String.valueOf(Integer.parseInt(strs[0]) / 2);
s2 = String.valueOf(Integer.parseInt(strs[1]) / 2);
handledItem = "{" + s1 + "," + s2 + "}";
matcher.appendReplacement(sb, handledItem);
}
matcher.appendTail(sb);
StringFileBridge.string2File(sb.toString(), output);
}
StringFileBridge.java
[java] package org.bruce.image.handler.divider;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.Reader;
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
/**
* 字符串与文件相互转换工具
* @author leizhimin 2009-7-14 15:54:18
*/
public class StringFileBridge {
/**
* 读取文件为一个内存字符串,保持文件原有的换行格式
* @param file 文件对象
* @param charset 文件字符集编码
* @return 文件内容的字符串
*/
public static String file2String(File file, String charset) {
StringBuffer sb = new StringBuffer();
try {
FileInputStream fis = new FileInputStream(file);
InputStreamReader isr = new InputStreamReader(fis, charset);
BufferedReader br = new BufferedReader(isr);
LineNumberReader reader = new LineNumberReader(br);
String line;
while ((line = reader.readLine()) != null) {
sb.append(line).append(System.getProperty("line.separator"));
}
reader.close();
} catch (Exception e) {
e.printStackTrace();
}
return sb.toString();
}
public static String changeEncode(String unicodeStr, String charset) {
String utf8Str = null;
try {
utf8Str = new String(unicodeStr.getBytes(charset));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return utf8Str;
}
/**
* 将字符串存储为一个文件,当文件不存在时候,自动创建该文件,当文件已存在时候,重写文件的内容,特定情况下,还与操作系统的权限有关。
* @param text 字符串
* @param distFile 存储的目标文件
* @return 当存储正确无误时返回true,否则返回false
*/
public static boolean string2File(String text, File distFile) {
if (!distFile.getParentFile().exists()) {
distFile.getParentFile().mkdirs();
}
BufferedReader br = null;
BufferedWriter bw = null;
boolean flag = true;
try {
&nb
补充:移动开发 , IOS ,