473,395 Members | 1,670 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

error in seek() class

natie
5
I'm new in java and while I was working on a project which had DataInputStreams etc, my compiler show me this error:

symbol : method seek(int)
location: class java.io.DataInputStream
F.seek(0);

I read in a forum that seek() is only for long types..
Is it correct?

what i'm going to do now?

thanks
Jan 14 '11 #1

✓ answered by horace1

not if you sequentially access the file, when you open the file the first record read/written would be the first, etc etc
You would use seek() if you need to randomly access it, i.e. move to a record without accessing all the records in between

5 1998
horace1
1,510 Expert 1GB
the DataInputStream does not have seek() method acording to the documentation
http://download.oracle.com/javase/6/...putStream.html

are you thinking of RandomAccessFile
http://download.oracle.com/javase/1....ccessFile.html

which does have a seek() method
http://download.oracle.com/javase/1....seek%28long%29
Jan 14 '11 #2
natie
5
oh thanks.. I understood it now I think better..
and can I ask smthng more? in RandomAccess Files, do we have to use always seek method?

and somthng more: for instance, the F.seek(0); /*if F is our file*/ goes us to the top of our file.. do we have to declare above our class something or not?
Jan 14 '11 #3
horace1
1,510 Expert 1GB
not if you sequentially access the file, when you open the file the first record read/written would be the first, etc etc
You would use seek() if you need to randomly access it, i.e. move to a record without accessing all the records in between
Jan 14 '11 #4
natie
5
if for example I have a a class which concludes a method in which I write something in a file, and another which searches for something specific in the same file, and the main class uses both of them. In the second method,do I have to use the seek method?
hmm it's getting weird! :|
Jan 14 '11 #5
horace1
1,510 Expert 1GB
it all depends on what your specification is.
If it is simple in that you write data to a file, close it, then open and read sequentially you don't need seek().
However, if you are writing and reading randomly to different parts of the same file you will need to use seek() to a particular record or rewind (seek(0)) then sequentially search.
What exactly do you need to do? I think you need to clarify this!
Jan 16 '11 #6

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

Similar topics

4
by: Martin Franklin | last post by:
I am trying to get a total record count on a Acess 97 mdb database. However I get the following error when I try to load the page: Provider error '80040154' Class not registered...
13
by: Duron | last post by:
I created a new folder using VS.NET 2003. Then I created a new web form under that folder, say, \Member\Default.aspx. However, even if I didn't do anything to that page, a run-time error appears...
0
by: Herman Jones | last post by:
I'm getting the following error when I build a Class Library project: Embedding manifest... Project : error PRJ0002 : Error result 1 returned from 'C:\WINDOWS\system32\cmd.exe'. It happens with...
2
by: bubzilla | last post by:
Hi, i´ve got about 10 headerfiles with implemented classes. Now when i try to compile them i get the following message: In file included from Proxy/ServerCnx.hh:36, from Proxy/Payload.hh:30,...
3
by: eholz1 | last post by:
Hello php group, I have a dev server running php 5.0 and apache 2.2, I have created some php files that create classes, etc All works well with this. But when I copy the files to my hosting...
3
by: krunalb | last post by:
hi, I am facing compilation error for following snippet: Compilation Error: t7.cc:17: error: expected `)' before '*' token <code snippet>
5
by: gyre | last post by:
Hi! I've got a little problem I've been dealing with for several days :(( Code is written in Qt. I'll try to explain it: I created an abstract class "VcaNode" with 4 virtual methods and 3 other...
2
oll3i
by: oll3i | last post by:
my server is complaining about error: Wrapper class grabber.SetLastNameNull is not found. Have you run APT to generate them? when i dont have SetLastNameNull function i have setLastNameNull...
2
by: elmbrook | last post by:
Hi I would like to create a custom error handling class and am not sure how to go about it. Try/Catch statements work however, if I am outside of that statement then the VS2008 debugger comes...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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,...
0
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
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...

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.