aspose file tools*
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 Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "urgent ..please look at code " Watch "urgent ..please look at code " New topic
Author

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.
pradeep

import java.io.*;
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 = in.read()) != -1){
System.out.println("ch4="+(char)c);
char ch=(char)c;
while ((c >= 'a' && c <= 'z' )|| (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')){
c=in.read();
System.out.println("ch="+(char)c);
}
pos=in.getFilePointer();
in.seek(pos-1);//here i am trying to go one character back to get to
// the EOF character
System.out.println("2");
}//while
}//main
}//MARK


SCJP1.4,SCBCD
Failure is not when you fall down; its only when you fail to get up again.
Rajesh Kumar
Greenhorn

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
rajeesh,
I am using the
in.seek(pos-1);

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
thanks
pradeep
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: urgent ..please look at code
 
Similar Threads
Ecryption program question
still puzzled about java and life!
urgent please help...look at code
Converting Infix to Postfix Expressions
characters and numbers seperation in a string