का उपयोग करके फ़ाइलें लॉग इन करने के फ़ाइल लॉग इन करने की प्रक्रिया उत्पादन & त्रुटि धारा लिखने के लिए एक अच्छा उदाहरण मिलता है। मैं अपनी प्रक्रिया निष्पादित करने के लिए अपाचे-कॉमन्स निष्पादन लाइब्रेरी का उपयोग करता हूं। एक कोड नमूना के बाद यह प्रदर्शित करने के लिए किलेखन आउटपुट और त्रुटि मैं थोड़ी देर के लिए खोज रहे होते PumpStreamHandler
public static int executeCommand(CommandLine command, Logger log) throws ExecuteException, IOException {
DefaultExecutor executor = new DefaultExecutor();
executor.setExitValue(0);
PumpStreamHandler psh = new PumpStreamHandler();
executor.setStreamHandler(psh);
return executor.execute(command);
}