2
GttService myService = new GttService("ex1cor.ex1Ap.1");
myService.setUserCredentials("[email protected]", "password");
DocumentEntry entry = new DocumentEntry();
// Set source language
String srcLang = "en";
entry.setSourceLanguage(new SourceLanguage(srcLang));
// Set target language
String targetLang = "ja";
entry.setTargetLanguage(new TargetLanguage(targetLang));
// Set title
String title = "Test";
entry.setTitle(new PlainTextConstruct(title));
// Set local file for upload.
String filename = "D:\\translate\\english.txt";
File file = new File(filename);
String mimeType = "text/plain";
MediaFileSource fileSource = new MediaFileSource(file, mimeType);
MediaContent content = new MediaContent();
content.setMediaSource(fileSource);
content.setMimeType(new ContentType(mimeType));
entry.setContent(content);
URL feedUrl = new URL("http://translate.google.com/toolkit/feeds/documents");
DocumentEntry resultEntry = myService.insert(feedUrl, entry);
什麼也沒發生。沒有錯誤...只是沒有!