String commentChar,
boolean allowEscapes,
String encoding) throws IOException {
PushbackBufferedReader lineReader;
if(file instanceof StringVector) {
String fileName = ((StringVector) file).getElementAsString(0);
if(fileName.length() == 0) {
lineReader = context.getSession().getConnectionTable().getStdin().getReader();
} else {
SEXP fileConn = Connections.file(context,fileName,"o",true,encoding,false);
lineReader = Connections.getConnection(context, fileConn).getReader();
}
} else {
lineReader = Connections.getConnection(context, file).getReader();
}
Splitter splitter;
if(Strings.isNullOrEmpty(seperator)) {
splitter = new WhitespaceSplitter(quote);
} else {
splitter = new CharSplitter(quote, seperator);
}
Scanner scanner;
if(what instanceof ListVector) {
scanner = new ListReader((ListVector)what, splitter);
} else {
scanner = new ScalarReader(getAtomicScanner(what), splitter);
}
String line;
int linesRead = 0;
int linesSkipped = 0;
while( (linesRead < nlines || nlines <= 0) &&
(line=lineReader.readLine())!=null) {
if (linesSkipped < skip) {
linesSkipped++;
continue;
}
linesRead ++;