Read a file character by character/UTF8: Difference between revisions
→{{header|Java}}
Line 378:
public class FileUtil {
FileReader reader;
String readFile(String path) throws IOException {▼
FileReader reader = new FileReader(path, UTF_8);▼
/** cast the returned value to 'char' */
int next() throws IOException {
try {
▲ int value;
/* 'read' will return 0 through 0xffff, and -1 for EOS */
} catch (IOException
reader.close();
throw exception;
}
return
}
}
void close() throws IOException {
reader.close();
}
}
|