我把我的超級語句以正確的格式,但我唯一的錯誤是,它聲明類java.lang.object中的構造函數對象不能應用於這部分代碼的給定類型:如何修復我的超級語句?
super (openFile (filename));
這是我現在當前的代碼:
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Vector;import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
public class Buffin
{
private static boolean temp;
/////////////////////////////////
private boolean isKeyboard;
/** Connect to the disk file with the given name. If this
* cannot be done, connect to the keyboard instead. */
public Buffin (String filename)
{ super (openFile (filename));
isKeyboard = temp;
} //======================
private static Reader openFile (String filename)
{ try
{ temp = false;
return new FileReader (filename); // IOException here
}catch (IOException e)
{ temp = true;
return new InputStreamReader (System.in);
}
} //======================
/** Read one line from the file and return it.
* Return null if at the end of the file. */
public String readLine()
{ if (isKeyboard)
{ System.out.print (" input> ");
System.out.flush(); // flush the output buffer
}
try
{ return super.readLine(); // in BufferedReader
}catch (IOException e)
{ System.out.println ("Cannot read from the file");
return null;
}
} //============
}[/code]
沒有'Object'構造函數接受'Reader'。 –
請按照編譯器告訴你的說明!由於'Reader'沒有'(Object)'的構造函數 – Rugal