{ p = Runtime.getRuntime().exec(command); errorStream = new StreamThread(p.getErrorStream()); outputStream = new StreamThread(p.getInputStream()); inputStream = p.getOutputStream(); errorStream.start(); outputStream.start(); } public void send(String in) throws Exception { inputStream.write(in.getBytes()); inputStream.flush(); inputStream.close(); } public void send(InputStream in) throws Exception { StreamUtils.streamCopy(in, inputStream); inputStream.flush(); inputStream.close(); } public int waitFor() throws Exception { int exitVal = p.waitFor(); return exitVal; } /** * * return error * * @return @throws * Exception */ public String getErrorString() throws Exception { String str = errorStream.getBuffer(); return str; } /** * * return output * * @return @throws * Exception */ public String getOutputString() throws Exception { String str = outputStream.getBuffer(); return str; } /* * wait for stream threads to die * */ public void waitForThreads() throws Exception { outputStream.join(); errorStream.join(); }
{ this.p = Runtime.getRuntime().exec(command); errorStream = new StreamThread(p.getErrorStream()); outputStream = new StreamThread(p.getInputStream()); inputStream = p.getOutputStream(); errorStream.start(); outputStream.start(); } public void send(String in) throws Exception { inputStream.write(in.getBytes()); inputStream.flush(); inputStream.close(); } public void send(InputStream in) throws Exception { StreamUtils.streamCopy(in, inputStream); inputStream.flush(); inputStream.close(); } public int waitFor() throws Exception { int exitVal = p.waitFor(); return exitVal; } /** * * return error * * @return * @throws Exception */ public String getErrorString() throws Exception { String str = errorStream.getBuffer(); return str; } /** * * return output * * @return * @throws Exception */ public String getOutputString() throws Exception { String str = outputStream.getBuffer(); return str; } /* * wait for stream threads to die * */ public void waitForThreads() throws Exception { outputStream.join(); errorStream.join(); }
Clone fragments detected by clone detection tool
File path: /columba-1.4-src/mail/src/main/java/org/columba/mail/spam/spamassassin/IPCHelper.java File path: /columba-1.4-src/core/src/main/java/org/columba/core/base/IPCHelper.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
{
1
{
2
        p = Runtime.getRuntime().exec(command);
2
	this.p = Runtime.getRuntime().exec(command);
3
        errorStream = new StreamThread(p.getErrorStream());
3
	errorStream = new StreamThread(p.getErrorStream());
4
        outputStream = new StreamThread(p.getInputStream());
4
	outputStream = new StreamThread(p.getInputStream());
5
        inputStream = p.getOutputStream();
5
	inputStream = p.getOutputStream();
6
        errorStream.start();
6
	errorStream.start();
7
        outputStream.start();
7
	outputStream.start();
8
    }
8
    }
9
    public void send(String in) throws Exception {
9
    public void send(String in) throws Exception {
10
        inputStream.write(in.getBytes());
10
	inputStream.write(in.getBytes());
11
        inputStream.flush();
11
	inputStream.flush();
12
        inputStream.close();
12
	inputStream.close();
13
    }
13
    }
14
    public void send(InputStream in) throws Exception {
14
    public void send(InputStream in) throws Exception {
15
        StreamUtils.streamCopy(in, inputStream);
15
	StreamUtils.streamCopy(in, inputStream);
16
        inputStream.flush();
16
	inputStream.flush();
17
        inputStream.close();
17
	inputStream.close();
18
    }
18
    }
19
    public int waitFor() throws Exception {
19
    public int waitFor() throws Exception {
20
        int exitVal = p.waitFor();
20
	int exitVal = p.waitFor();
21
        return exitVal;
21
	return exitVal;
22
    }
22
    }
23
    /**
23
    /**
24
     *
24
     
25
    * 
25
     * return error
26
         * return error
26
     *
27
      
28
   * 
27
     * @return @throws
29
         * @return
28
     *         Exception
30
         * @throws Exception
29
     */
31
         */
30
    public String getErrorString() throws Exception {
32
    public String getErrorString() throws Exception {
31
        String str = errorStream.getBuffer();
33
	String str = errorStream.getBuffer();
32
        return str;
34
	return str;
33
    }
35
    }
34
    /**
36
    /**
35
     *
37
         *
38
 
36
     * return output
39
         * return output
37
     *
40
         *
41
 
38
     * @return @throws
42
         * @return
39
     *        
40
 Exception
43
         * @throws Exception
41
     */
44
         */
42
    public String getOutputString() throws Exception {
45
    public String getOutputString() throws Exception {
43
        String str = outputStream.getBuffer();
46
	String str = outputStream.getBuffer();
44
        return str;
47
	return str;
45
    }
48
    }
46
    /*
49
    /*
47
     * wait for stream threads to die
50
         * wait for stream threads to die
48
     *
51
      
52
   * 
49
     */
53
         */
50
    public void waitForThreads() throws Exception {
54
    public void waitForThreads() throws Exception {
51
        outputStream.join();
55
	outputStream.join();
52
        errorStream.join();
56
	errorStream.join();
53
    }
57
    }
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0