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 Android Security Essentials Live Lessons this week in the Android 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.

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){
char ch=(char)c;
while ((c >= 'a' && c <= 'z' )|| (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9')){
in.seek(pos-1);//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
It is sorta covered in the JavaRanch Style Guide.
subject: urgent ..please look at code
Similar Threads
characters and numbers seperation in a string
Converting Infix to Postfix Expressions
Ecryption program question
urgent please help...look at code
still puzzled about java and life!