Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp

Eugene Armistead

Greenhorn
+ Follow
since Jul 12, 2001
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Eugene Armistead

Dirk,
Thanks for the web page suggestion! That page is exactly the sort of thing that I am looking for. It's a great resource.
Regards,
Eugene
17 years ago
Hi All,
I recently passed my SCJP and am ready to really get into it and get some good experience - thereby furthering my career. As everyone knows, the best way to get really fluent in Java is to write tons of code.
My problem is that I find myself short of projects to work on. I have several utilities I wrote in VB that I have now re-done in Java and anything that comes up at work I immediately try and solve with a short Java program. I've done a few simple JSP/Servlet combos with JDBC access.
Where else can I find manageable projects to work on in my spare time? Some books have chapter end exercises that I have been able to work through, but they don't usually have any direct real-world application. They teach you how to do something specific from that chapter which can in turn be applied to real-world stuff.
I was just wondering where other folks went for inspiration for intermediate level projects to practice their coding before trying to get into a bigger/advanced project. I have a few ideas from looking at the Java Cookbook, but where else can I find stuff? I don't really have any Java programming problems to solve (yet), so I have stayed away from the design patterns books, but is that the place to start?
Your help and input is appreciated!
17 years ago
Hi Kathy/Steve,
Kathy's method worked perfectly.
Thank you both for your help!
regards,
18 years ago
Hi,
This may be kind of a beginner question, but please bear with me.
I am working in Windows and am writing an application that takes a configuration file written by another program, lets the user modify the configurations, and then writes the file back out in the same format as the original.
My problem is that I can't get the output to look right. When I view the file in NOTEPAD, it looks something like:
LINE ONE INFORMATION
LINE TWO INFORMATION
LINE THREE INFORMATION
and so on. When I write it back out, I get:
LINE ONE INFORMATION<\N>LINE TWO INFORMATION<\N>LINE THREE INFORMATION<\N>
and so on, where '<\N>' is the control character for new line.
When I look at my file in NOTEPAD, I get results as mentioned above. If I use a more advanced editor like TEXPAD, which can recognize the new line character, my file looks fine and is indistinguishable from the original. The problem is that the program that uses this config file parses by line and has trouble reading my output file.
I have tried using FileOutputStream and FileWriter API's. I have tried sending Char Arrays, String Arrays and straight Strings. Writing output a line at a time, writing with the whole thing as one String with '\n' in the proper places - all with no luck. What would be a proper way to get each line formatted correctly?
18 years ago
Hi,
I am starting to learn about RMI and I am running into a problem that I'm sure has a simple answer:
I am working on the examples in CORE JAVA, Volume II and on page 266-267 there is a simple example of an RMI Server. I typed in all of the code and it complies fine, but when I run it, I get an error that I can't connect to my localhost. I put a security policy file in (exactly like in the book) and started my server with the policy. I have TCP/IP running on Windows 2000 and everything is in the same directory. I am trying to start the registry on the default port. Here is how I am starting everything up (note that in the below example the IP is not my local host as I tried running this while connected to a dial-up network connection - I get the same results with the localhost IP if I am not on line and just have my NIC running):
E:\temp> dir
Volume in drive E has no label.
Volume Serial Number is C0A4-4886
Directory of E:\temp
10/24/2001 09:39p <DIR> .
10/24/2001 09:39p <DIR> ..
10/24/2001 09:01p 79 client.policy
10/24/2001 08:53p 219 Product.class
10/24/2001 08:53p 166 Product.java
10/24/2001 08:54p 630 ProductImpl.class
10/24/2001 08:52p 438 ProductImpl.java
10/24/2001 08:55p 1,434 ProductImpl_Skel.class
10/24/2001 08:55p 2,876 ProductImpl_Stub.class
10/24/2001 08:54p 1,098 ProductServer.class
10/24/2001 08:48p 777 ProductServer.java
9 File(s) 7,717 bytes
2 Dir(s) 7,615,070,208 bytes free
E:\temp> start rmiregistry
E:\temp> java ProductServer -Djava.security.policy=client.policy
Constructing server implementations...
Binding server implementations to registry...
***Error: java.rmi.ConnectException: Connection refused to host: 205.173
.118.189; nested exception is:
java.net.ConnectException: Connection refused: connect
E:\temp>
What am I doing wrong???
Thanks for your help.
18 years ago
Hi Angela,
This works perfect for what I need. Thanks for your help!
Regards,
Hi,
I have an Object that gets locked by various threads via a synchronized block. Something Like:
class MyThread extends Thread{
public void run(){
synchronized(someObject){
// do stuff to some Object
}
}
}
Is there an easy way to have an another instance of MyThread examine "someObject" and see if it is locked by another thread? This way I could tell the user something like "waiting for locked resource..."
Thanks
Thanks for the tips. They work just fine!
18 years ago
Hi,
Can anyone tell me if there is an easy way to convert a String object that represents a path to a File object?
I have a method that accepts a File object as an argument, but I have a String that that is the path to that file, i.e. "c:\MyProgs\data.txt" and I'd like to pass a reference to the File "data.txt"
Thanks,
18 years ago
Hi,
I'm not sure if this is better suited for one of the other forums, but here goes....
I was speaking with a Java instructor the other day about creating a program in Java similar to a Napster-type program.
He mentioned that I could pass multimedia files over the network byte by byte with stream readers/writers, but a better way to do it was to create an object that holds a file of the type I'd like to pass. Then, all I would have to do is pass the object over the network.
For example, he said that an MP3 file has a certain internal structure and I would just need to create an object that is designed to hold that structure.
My question is: how would I find out these internal structure formats and then go about creating an object to hold this type of file? Would it be some sort of wrapper class or can you parse an MP3 file into its components?
Thnx and regards....
18 years ago