LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 03-30-2005, 03:37 PM   #1
dolvmin
Member
 
Registered: Jul 2003
Location: Florida
Distribution: Red Hat 7.2/8/9, Fedora Core 1/2/3, Smoothwall, Mandrake 7.0/10, Vecter 4, Arch 0.6, EnGuarde
Posts: 289

Rep: Reputation: 30
Java (File Search Problem)


I need help. I'm working on a program that will load several files with the file extension *.tmp. However the program's search can not be case insensitive.

I can write up a static String based on 8 constants regarding to this problem, but I feel that is a very weak method of programing. Further more, if I have to create an extension to the program, by seeking out other file extensions, using the static String idea would at that point be ridiculous.

I've gone through .toUpperCase(), .toLowerCase() references from the java API, but they don't answer my questions. This is driving me mad, I been on it for five hours. Can someone help me please?
 
Old 03-30-2005, 07:23 PM   #2
dolvmin
Member
 
Registered: Jul 2003
Location: Florida
Distribution: Red Hat 7.2/8/9, Fedora Core 1/2/3, Smoothwall, Mandrake 7.0/10, Vecter 4, Arch 0.6, EnGuarde
Posts: 289

Original Poster
Rep: Reputation: 30
Problem fixed. Here's a sample for those who were going to help...
This line is outside the method of which provides the extension.
Code:
private static String fileExtention = ".txt";
This line provides an understand of what is happening when the file is being opened
Code:
File fileOpen = new File("c:/temp/myfile" + fileExtention);
Java will automatically provide a case insensitive search for the file myfile.txt.

This was my prior mistake
Code:
File fileOpen = new File("c:/temp/myfile.txt");
The only error that will be found is if "myfile" requires a case insensitive search.

In circumstances like that, this may be an option to consider Be sure to place this outside the method.
Code:
private static String fileName = "myfile";
private static String fileExtention = ".txt";
This goes within the method
Code:
File fileOpen = new File("c:/temp/" + fileName + fileExtention);
This is untested, but I'm sure it will work. Thanks for viewing my posts.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Java - Search for alt or ctrl modifiers in a string meblost Programming 0 03-26-2005 09:44 AM
Find File broken, need search utility, where does WineX install, KDE file roller? Ohmn Mandriva 6 07-05-2004 10:34 PM
How to 'apt-cache search' & 'apt-file search' by distribution? davidas Debian 3 04-19-2004 01:56 PM
Binary search tree insertion in java ksgill Programming 6 02-12-2004 05:11 PM
Console file search "problem" JZL240I-U Linux - General 4 08-07-2003 01:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration