PDA

View Full Version : Java help



gimp
12-06-2004, 09:38 PM
Ok, so I don't really know java, but I've managed to get most of my java project done. Anyway, I need some help. I've got a file object, and I need to open it in its default windows application. For example, I want txt documents to open in notepad, pdf files to open in adobe. If anyone knows how to do this it would be really helpful.

Thanks!

Jonneh
12-06-2004, 09:40 PM
What you're asking doesn't make sense.

gimp
12-06-2004, 09:50 PM
Ok, I'll try to elaborate. I have a file object like this:

File opening = new File("C:/gimp/textfile.txt");

How would I open that file in notepad from a java application?

Miscue
12-06-2004, 09:53 PM
Ok, I'll try to elaborate. I have a file object like this:

File opening = new File("C:/gimp/textfile.txt");

How would I open that file in notepad from a java application?

Have it output: "Dear user, please double-click the following file:" :p

I dunno how to do it offhand... Jonneh might be able to figure it out.

gimp
12-06-2004, 09:55 PM
hehe, well. That's pretty much what I have. I've got the button all set up, I just don't know how to make it do what it's supposed to.

Kevmaster
12-06-2004, 09:55 PM
so your java gui is supposed to allow the user to select a file and it will open the file with its natural application?

thats a toughie...

Miscue
12-06-2004, 10:03 PM
I think you have to get Java to use the Windows API for that - not sure.

gimp
12-06-2004, 10:04 PM
Yeah. I have a list of files and you can select a file from that list to open. You can either double click it, or you can select it and open it with an 'open' button. In case anyone is curious what the program actually is, I'll give you a quick run through. It's a search program, but it doesn't search for words, it searches for documents of similar subject matter. For example, if you have a pdf about automags, you could say 'find similar documents', and it would find other (right now it just searches your computer, but it could easily be moved to search networks and such) documents that talk about automags and rate them by how relevent they are. It's kind of neat how it actually searches. That wasn't my part of the project, but it's pretty neat.

Kevmaster
12-06-2004, 10:48 PM
that is neat! I'd love to see the source code when you're done.

I'll look inthe JAVADOC and see if i can find anything aobut that...but i've never run into that problem

mikey101
12-07-2004, 12:24 AM
i made a small class that would open up .dat/.txt files that were filled with 5 letter words later used in a sort routine. not sure if it would open other extensions with their intended app though. I don't have it with me now, but i can get it off the schools comp tomorrow morning if you still need it. may not be exactly what you want, but it's a start.

off topic..but does the search you use hash all of the files it finds and then sort them by comparing the hashes? this sounds pretty interesting, i'd like to know more about how it works :cheers: