Hi there
I am a Java newbie so if you want to ignore me with reviled distaste that is ok
:)

I am just looking for some advice:

I want to create a program that checks a .txt file entered at the first line by the user (command line?) against a particular string of letters (sequence?).

I have decided to separate my program into a few stages:
1. Welcome and ask for File to be searched
If not in same directory, program terminates asking to check whether file is in same directory.
If in same directory, move onto stage 2
2. Read file to make sure that there are just letters (i.e no numbers)
If there are numbers, program terminates asking for numbers to be removed from .txt file.
If there are no numbers, program continues to stage 3
3. Read file to make sure there are no spaces. If spaces exist then join them.
4. If letters are in small then capitalise them.
5. If I wanted to find a word all the words beginning with a and ending with z in the text then I coul also use a*z

I will post updates to let you know how I am doing
If anyone can help. Thanks

boolean exists = (new File("farrago.txt")).exists();
if (exists) {
System.out.println("File is in same directory as program. Thank You");
// File or directory exists
} else {
System.out.println("File is not in directory. Please check that file is in same directory as program. Thank You");
// File or directory does not exist
}

I have got the following for the first part, but I know this will only check whatever is in farrago.txt . Is there anyway to convert the above to only check for a file entered at the command line?

02-14-2006, 06:41 AM

derekfiedler

Try 2

What I have tried doing si scombining some of the classic Read Name program with the second part:

boolean exists = (new File(BufferedReader)).exists();
if (exists) {
System.out.println("File is in same directory as program. Thank You");
// File or directory exists
} else {
System.out.println("File is not in directory. Please check that file is in same directory as

program. Thank You");
// File or directory does not exist
}

02-14-2006, 06:24 PM

nspils

Are you looking just for file names or are you looking to input a "search phrase" and then wanting to scan the content of files in a location for that phrase?