473,480 Members | 1,922 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

randomaccessfile versus bufferedreader

73 New Member
I want to know which one will be faster randomAccessFile or Bufferedeader. I am reading a file about 18 MB. For that using randomAccessFile i will read from the beginning of the file the first time and i will get the position of file pointer depending on the line's data and after that i will start reading from the position of file pointer. this will happen for each call of one method that i wrote..... initially i used BufferedReader but it was slow.....so i tried randomAccessFile..but i feel its very slow the first time it goes thru the file......there is a method mark in BufferedReader....but for that the parameter is the number of characters that i will read after that position.But i don't know the number of characters......so,i am really confused wat to do...My r/qment is: I want to read the file fully only once when my method is called.....and then after i will read from the position i have marked....pls help... i want to read the file faster
Sep 2 '07 #1
2 5691
JosAH
11,448 Recognized Expert MVP
If you're talking Readers you're talking text files. 18MB isn't that much so I'd
suggest a simple List<String> that contains all the lines of the file. If that is too
slow for your purposes, please elaborate a bit on *what* exactly you want to do
with that data.

I vaguely remember about another thread of yours dealing with the very same issue.

kind regards,

Jos
Sep 2 '07 #2
jyohere
73 New Member
I have a file that gets appended with data for every 15 minutes.....initially when i read the file with bufferedReader when the file is small it works fast...but as the file size grows bigger, the execution goes slow.....
Sep 3 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
15588
by: Dr.Kadzija | last post by:
i have a client-server application. client and server should communicate via tcp sockets. ok, so i use Sockets, PrintWriter and BufferedReader. the problem is that: both client and server will send...
1
4701
by: Morten | last post by:
Hi. I have a file using \n as line-separator. There are also occurrences of \r in the file, but I don't want the BufferedReader.readLine() to consider those as EOL. Apart from stripping all \r...
3
5362
by: shana07 | last post by:
I have downloaded one image program and about to understand it. This is from its documentation: * image.setInput(in); // in can be InputStream or RandomAccessFile I run the java class from...
1
6416
kaleeswaran
by: kaleeswaran | last post by:
what is difference between -BufferedReader and InputStreamReader.. which one is efficent?..
5
6449
by: angelotti | last post by:
Hi everyone , i have the following problem , i read data from another application that i started through the runtime.exec() in my Java class. I need to periodically check if there is any data...
0
1600
by: irkahs | last post by:
Hey all, Need some Java help here. This is a code fragment that does a few things. 1) Allows adding to a RAF file. 2) Searches for a match and displays related records. and
1
2221
by: sassoon12 | last post by:
hi. Is it possible to use bufferedreader in an applet? if so where am i going wrong here ? im getting the following error: E:\CIS26\Hw1App.java:23: unreported exception java.io.IOException; must be...
7
11040
dmjpro
by: dmjpro | last post by:
Hi All .... I am trying to edit a file using RandomAccessFile. I am having a little bit problem. My file is ... i m debasis jana.
11
3365
by: brendanmcdonagh | last post by:
Hi all, I'm struggling with a challenge on new learnings about reading and writing from a txt file. Now I have just learnt about the Scanner class and i can usedelimiter (",") to create tokens....
0
7037
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6904
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7032
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6730
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
6873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4471
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2990
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
174
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.