本文改写于:http://www.cnblogs.com/skyme/archive/2011/05/14/2046040.html
1、下载并安装git:
在git-scm.com上下载并安装git,安装后它会自动加载在windows右键菜单中。
2、生成下载命令列表:
git下载的格式形如:
git clone https://android.googlesource.com/name
把name换成具体的目录即可,android源码的目录极多,手动手写太过繁杂,改写文章提供了一个java程序用来生成命令列表,但android源码已经由http://android.git.kernel.org/转到https://android.googlesource.com/,条目格式也有变化,所以本文改写了这个java程序源码。
首先,把https://android.googlesource.com/页面中的目录列表都复制到一个文本文件中去。本文提供的java程序源代码要求放在c盘根目录,当然你可以放在其它目录(只要你相应地更改java源代码);本文提供的java程序源代码还要求文件名为:androidURL.txt,当然你也可以改掉它。
java程序源代码如下:
import java.util.*; import java.io.*; public class ReplaceFile { /** * @param args */ public static void main(String[] args) { String fileName = "C:/androidURL.txt"; readFileByLines(fileName); } private static void readFileByLines(String fileName) { List<String> tmpList = new ArrayList<String>();// 用来存放修改后的url File file = new File(fileName); BufferedReader reader = null; try { System.out.println("以行为单位读取文件内容,一次读一整行:"); reader = new BufferedReader(new FileReader(file)); String tempString = null; int line = 1; // 一次读入一行,直到读入null为文件结束 while ((tempString = reader.readLine()) != null) { // 显示行号 String splitByStr = "\011"; int tmpI = tempString.indexOf(splitByStr); if(tmpI == -1){ String gitGet = "git clone https://android.googlesource.com/"; // System.out.println("line " + line + ": " + gitGet // + tempString + splitByStr); System.out.println(gitGet + tempString); tmpList.add(gitGet + tempString); } else if (tmpI >= 0) { tempString = tempString.substring(0, tempString.indexOf("\011")); String gitGet = "git clone https://android.googlesource.com/"; // System.out.println("line " + line + ": " + gitGet // + tempString + splitByStr); System.out.println(gitGet + tempString); tmpList.add(gitGet + tempString); } line++; } reader.close(); } catch (IOException e) { e.printStackTrace(); } finally { if (reader != null) { try { reader.close(); } catch (IOException e1) { } } } } }