Created On:  05 January 2010

Problem:

Checkout all files from a project to a custom directory location, using StarTeam SDK.

Resolution:

Disclaimer: This is a sample code only provided to give an idea. Micro Focus is not responsible to support this code:

import com.starbase.starteam.File;
import com.starbase.starteam.Folder;
import com.starbase.starteam.CheckoutManager;
import com.starbase.starteam.Item;
import com.starbase.starteam.Label;
import com.starbase.starteam.Project;
import com.starbase.starteam.Server;
import com.starbase.starteam.View;
import java.io.*;


public class CheckoutAllFiles{
public static void main(String[] args){
String serverAddress = "serverName";
int port = 49201; //port number
String user = "UserName";
String pass = "Password";
String projectName = "Project_In_Question";

//===create StarTeam Server Object
Server srv = new Server(serverAddress, port);
//===logon as user, pass
srv.logOn(user, pass);
Project[] projects = srv.getProjects();
Project result = null;
for (int i = 0; i < projects.length; i ) {
Project next = projects;
System.out.println(projects.getName());
if (next.getName().equals(projectName)) {
result = next;
String str = "";
str = "bco.bat -p \"" user ":" pass "@" serverAddress ":" port "/";
str = str result.getName() "\" -is -vb -fs -o -fp \"c:\\test1\"";
runCommand(str);


}//if
}//for
}

public static void runCommand(String str){
try {
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(str);
BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
String line=null;
while((line=input.readLine()) != null) {
System.out.println(line);
}

int exitVal = pr.waitFor();
System.out.println("Exited with error code " exitVal);
} catch(Exception e) {
System.out.println(e.toString());
e.printStackTrace();
}

}
}