Please I am relatively new to Java and would really appreciate your help. Can anyone please tell me what I am doing wrong. I'm trying to send a string to an oracle and save it's output. My program just hangs when I get to this block of code.

        try {
            Process proc = Runtime.getRuntime().exec("ku1840.oracle");
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(
                                proc.getOutputStream()));
            bw.write(myAttackData.mString);
            bw.flush();

            BufferedReader br = new BufferedReader(new InputStreamReader(
                                proc.getInputStream()));
            String line = br.readLine();
            br.close();
            System.out.println(line);           
        } 

        catch (IOException e) {  
            e.printStackTrace();  
        }

Recommended Answers

All 4 Replies

You could try creating the input stream before you write anythung to the output stream - maybe there was a response but you missed it before you opened the input stream?
Anyway, add print statements at key points in that code so you can see exactly where it is hanging - exactly which statement?

You may also want to get the errorStream and see if that contains anything

Also look at the Error stream for error messages.

Thanks guys I was able to figure it out. My input wasn't of the correct format for the oracle

Hey Guys seems like I'm in a jam again. My oracle prints out 2 different lines of output. I stored them in two different variables usinng two readline functions but for some reason, some of them are coming up as null. Does anyone have any suggestions? As to why this may be happening.

        try {
            Process proc = Runtime.getRuntime().exec("ku1840.oracle");
            BufferedWriter buffW = new BufferedWriter(new OutputStreamWriter(
                                proc.getOutputStream()));
            buffW.write(myAttackData.mString);
            buffW.flush();

            BufferedReader buffR = new BufferedReader(new InputStreamReader(
                                proc.getInputStream()));
            trace = buffR.readLine();
            cipher = buffR.readLine();
            buffR.close();  
            System.out.println(trace);
            System.out.println(cipher);
        } 

        catch (IOException e) {  
            e.printStackTrace();  
        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.