java - Most efficient way to read characters from a file? -
while practising file i/o in java, came across assignment has rewrite method looks recorddata associated given record id. now, method i'm talking using filereader wrapped in bufferedreader in order read characters. oddly enough, assignment suggests using bufferedstreamreader(?) might not efficient way of retrieving characters file. find more confusing considering method contains bufferedreader instead of bufferedstreamreader.
so question is, isn't using bufferedreader wrapper filereader efficient (in terms of speed) way read characters in file?
edit: assignment talks of bufferedstreamreader, not bufferedinputstream
i haven't come accross bufferedstreamreader read characters using bufferedreader first string , character character if talking about.
fileinputstream fs = new fileinputstream(filename); bufferedreader br = new bufferedreader(new inputstreamreader(fs)); (int j = 0; j < 0; j++) {//the first line string str = br.readline().trim(); char[] chars = str.tochararray(); string first = string.valueof(chars[0]);//the first character string second = string.valueof(chars[1]);//the second }
Comments
Post a Comment