Nao consigo resolver este erro de compilação

2 respostas
I
import java.io.*;
import java.lang.*;


public class teste{

public static void main(String args[]){

String dataset =  "breast-w"; 
String ext =  ".arff";

String nome_dataset = dataset + ext;


String foldTest  = dataset +  "-test" + ext;
String foldTrain = nome_dataset;
String resultados = dataset + "_result.txt";

String cmdTrain =  "java -cp c:\weka\weka.jar weka.classifiers.trees.J48 -v -t " + foldTrain + " -T " + foldTest;

 
    try {
        // Execute command
        String command = "dir";
           System.out.println("1");
        Process child = Runtime.getRuntime().exec(command);
       System.out.println("2");
        // Get input stream to read from it
       BufferedReader in = new BufferedReader(child.getInputStream());
       try{
          String linha = "";
          while((linha = in.readLine()) != null){
                System.out.println(linha);
          }
       }
       catch(Exception e){
             e.printStackTrace();
       }
                    System.out.println("58");
    } catch (IOException e) {
    }

}

}

este codigo esta dando o erro abaixo mesmo com a importação da java.io

teste.java:30: cannot resolve symbol
symbol : constructor BufferedReader (java.io.InputStream)
location: class java.io.BufferedReader
BufferedReader in = new BufferedReader(child.getInputStream());
^
1 error

qual pode ser o problema?

2 Respostas

thadeurc

Te sugiro trocar o

new BufferedReader(child.getInputStream())

por

new BufferedReader(new InputStreamReader(child.getInputStream()))
I

eu coloquei estes 2 println pra ver se estava dando certo, porem nao imprimiu o segundo, tem alguma maneira de eu executar um comando q de certo?

System.out.println("1"); Process child = Runtime.getRuntime().exec(command); System.out.println("2");

Criado 18 de junho de 2006
Ultima resposta 18 de jun. de 2006
Respostas 2
Participantes 2