Created
January 23, 2013 12:43
-
-
Save lizhi525/4605137 to your computer and use it in GitHub Desktop.
游戏中批量生成游戏资源文件的版本号 和 体积 csv文件的程序
使用方法 java JMD5 游戏资源目录 >v.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @(#)JMD5.java | |
* | |
* java JMD5 F:\e\www\game >v.csv | |
* @author lizhi | |
* @version 1.00 2013/1/23 | |
*/ | |
import java.security.MessageDigest; | |
import sun.misc.BASE64Encoder; | |
import java.io.File; | |
import java.io.FileInputStream; | |
public class JMD5 { | |
public JMD5() { | |
} | |
public static void main (String[] args) { | |
if(args.length<1){ | |
System.out.println("input file dir"); | |
return ; | |
} | |
try { | |
System.out.println("local_relpath,revision,translated_size"); | |
dofile(new File(args[0]),""); | |
} | |
catch (Exception ex) { | |
ex.printStackTrace(); | |
} | |
} | |
public static void dofile(File file,String parent){ | |
if(file.isDirectory()){ | |
File[] files = file.listFiles(); | |
for(int i=0;i<files.length;i++){ | |
dofile(files[i],parent+file.getName()+"/"); | |
} | |
}else{ | |
try { | |
MessageDigest md = MessageDigest.getInstance("MD5"); | |
FileInputStream input = new FileInputStream(file); | |
byte[] bytes = new byte[(int)file.length()]; | |
input.read(bytes); | |
byte[] md5bytes = md.digest(bytes); | |
BASE64Encoder b64e = new BASE64Encoder(); | |
System.out.println(parent+file.getName()+","+b64e.encode(md5bytes)+","+file.length()); | |
}catch (Exception ex) { | |
ex.printStackTrace(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment