I've done that and I get the same error. Here's the class I'm trying to make available:
CODE
import java.io.*;
import javax.swing.JFileChooser;
public class IO
{
public static void print(Object string)
{
System.out.print(string);
}
public static void println(Object string)
{
System.out.println(string);
}
public static String readln() throws IOException
{
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
return stdin.readLine();
}
public static String readlnFromFile(String file) throws IOException
{
String readedString = "";
try {
BufferedReader stdin = new BufferedReader(new FileReader(file));
readedString = stdin.readLine();
} catch (IOException ex) {
}
return readedString;
}
public static String readlnFromUserSelectedFile() throws IOException
{
String readedString = "";
File file;
JFileChooser fileChooser = new JFileChooser();
fileChooser.setDialogTitle("Select file to read from");
fileChooser.showOpenDialog(null);
file = fileChooser.getSelectedFile();
try {
BufferedReader stdin = new BufferedReader(new FileReader(file));
readedString = stdin.readLine();
} catch (IOException ex) {
}
return readedString;
}
public static void writeToFile(String file, String string) throws IOException
{
try {
BufferedWriter stdout = new BufferedWriter(new FileWriter(file));
stdout.write(string);
stdout.close();
} catch (IOException ex) {
}
}
public static void writeToUserSelectedFile(String string) throws IOException
{
File file;
JFileChooser fileChooser = new JFileChooser();
fileChooser.setDialogTitle("Select file to write to");
fileChooser.showOpenDialog(null);
file = fileChooser.getSelectedFile();
try {
BufferedWriter stdout = new BufferedWriter(new FileWriter(file.getName()));
stdout.write(string);
stdout.close();
} catch (IOException ex) {
}
}
}
And here's the file that tries to use the class: (This is the file that won't compile)
CODE
public class Test
{
public static void main(String args[])
{
IO.println("Hello!");
}
}
The error I get says that the symbol: "variable IO" cannot be found. Am I doing something wrong?