Im making a program the that uses wild cards on files example /home/My*/n?w/*txt im trying to make a binary tree of paths because base on the example the My* can be MyDocu MyHome etc, at the n?w can be new naw etc and get all the txt files i dont know where to start on the program

Recommended Answers

All 4 Replies

You need to look up the file and directory routines of your compiler and/or operating system that's the starting points for this program then write some test programs to test what you are learning make them small and simple notice what happens when you don't bother writing in sentences just cramming all your sentences together makes it hard to understand you

You need to look up the file and directory routines of your compiler and/or operating system that's the starting points for this program then write some test programs to test what you are learning make them small and simple notice what happens when you don't bother writing in sentences just cramming all your sentences together makes it hard to understand you

Aside from this, Is there any way in creating on it?

You'll probably want to split the string based on the directory separator character ("/"). If it starts with "/" then you'll want to start with the root directory ("/"); otherwise start with the current directory (".").

Look at the "listFiles" methods on the java.io.File class. The one that accepts a 'FilenameFilter' parameter would probably be a bit more convenient or useful.

If figuring out how to process "*" and "?" is too difficult, consider translating them to regular expressions and using the 'java.util.regex' classes: http://download.oracle.com/javase/6/docs/api/java/util/regex/package-summary.html You'll need to "quote" the existing dot characters ("."), and then translate "?" to ".", and "*" to ".*".

You might want to use a language you already know. If you need to learn a language, then I suggest the Python programming language instead of Java. It has about the same expressive power as Java, a similarly powerful set of tools in the standard library, and in my opinion is easier to learn well enough to get useful results. Python's os.path module has most of what you will want, though you may want to use the os.walk() function to traverse your directory structure.

I am not recommending that you learn Python to do this... unless you need to learn your first programming language to get started, in which case, as I said, Python is a good choice.

WaltP's point is also a very good one: To program well requires that you cultivate an orderly, detailed understanding of what is needed and how to get there. Well structured text is one indication of that kind of thinking, though in my experience, spelling well is optional. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.