File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes urgent ..please look at code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "urgent ..please look at code " Watch "urgent ..please look at code " New topic

urgent ..please look at code

pradeep arum
Ranch Hand

Joined: Oct 01, 2003
Posts: 130
thanks ernest,
this is going into an infinite loop ,in.txt contains abcde ,please help,anybody.

public class MARK {
public static void main(String[] args) throws IOException {
RandomAccessFile in = new RandomAccessFile("in.txt","r");
int c,i=0,flag_T=0,j=0;
char cc;
long pos=0;
while ((c = != -1){
char ch=(char)c;
while ((c >= 'a' && c <= 'z' )|| (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')){;
pos=in.getFilePointer();;//here i am trying to go one character back to get to
// the EOF character

Failure is not when you fall down; its only when you fail to get up again.
Rajesh Kumar

Joined: Oct 25, 2003
Posts: 6
couple of thoughts...
No. 1:
In the code segment:

You may want to use 'ch' instead of 'c'
No. 2:
If you just get rid of:

your code will exit properly since by having this code, you are just
toggling the while loop between character- 'e' and EOF.
hope this helps.
- Rajesh
pradeep arum
Ranch Hand

Joined: Oct 01, 2003
Posts: 130
I am using the;

to position the file pointer back at the EOF character ,so that the outer while can exit properly,hope u got it? can you work on it now
I agree. Here's the link:
subject: urgent ..please look at code
It's not a secret anymore!