This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!

Brian Tomlin

Ranch Hand
+ Follow
since Dec 06, 2000
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 Brian Tomlin

I see your point. That makes sence to me now. Thanks for your explanation.
19 years ago
Oops, it didn't print my start and end blocks.
I use the ASCII Vertical Tab as the start block, and File Separator as the end block.
19 years ago
Can anyone suggest the best way to parse text from a socket?
I have a listener (server) that opens a socket and a client that connects to that socket on the server and sends data. I need to be able to parse this data and send a response back to the client.
The data to be parsed is sent in blocks of text identified with a start block of ASCII <VT> and an end block character of ASCII <FS>.
The first thing I need to do is look for the start block. If it does not exist, I will return and error string to the client. If it does, I will continue to read until I get to the end block. When I have the full string, I will file it in a RandomAccessFile and parse the string accordingly.
I am currently using a BufferedReader and the readLine method, but I'm not sure how to check for these start and end block characters.
Any suggestions would be greatly appreciated.
Brian
19 years ago
Thanks for quick reply Frank. Your solution works. This is what I wrote.

I have one question about this line of code.

Why was the DateFormat class introduced here? I was able to compile the code using this line too.

Is it necessary to intruduce another class, or am I missing something?
Thanks again,
Brian
19 years ago
Hi,
I am trying to create a log file using the RandomAccessFile class and use the current date in part of the file name. I am trying this using the Date class to get the current date but the file is not getting created, probably because I am not using the correct format.
This is what my code looks like.

I think the problem is the way that the date is formatted with the Date class. It looks like this.
Mon Feb 26 09:42:21 CST 2001
I would like to use a format that would create a file that looks something like "Server02262001.log"
I have looked for a method that would convert the date format to this, but I haven't found one. Maybe I'm not looking in the right place. Surely there is something already out there to do this.
Any suggestion?
Thanks,
Brian
19 years ago
Thanks Ryan, and Cindy.
Both are great suggestions. I have used args.length in the cattle drive assignments too, but I had forgotten about it. I guess I had a momentary lapse of reason. Thanks for the kick!
Brian
19 years ago
Hi Charles,
Check out the Sun turorial on Reading and Writing. Hope it helps.
http://java.sun.com/docs/books/tutorial/essential/io/index.html
19 years ago
Thanks Cindy,
I'll try that.
19 years ago
Can anyone tell me what is the best way to check for data passed to the main method in the args[0] parameter without causing this exception?
I want to be able to check for a parameter passed and if one does not exist I want to be able to assign a default value.
Thanks,
Brian
19 years ago
Frank,
You Da Man!!!
I saw that option before, but I didn't realize that I could create a new tool until you pointed it out. I just pointed to my javac executable in E:\jdk1.3\bin and created a new compiler tool and it works like a charm.
Thank you SO much.
Brian
19 years ago
Thanks Frank.
I verified that the PATH was correct, but there was not an entry in the CLASSPATH. I was under the impression that this was no longer required. I went ahead and put the "." for the CLASSPATH it still wouldn't work.
I then remembered that I had copied the compiler into C:\WINNT\SYSTEM32 to fix a previous error that I got when I tried to compile using TextPad. I deleted this copy of javac and tried to compile from the command line and got a clean compile. However, If I try to compile using TextPad, I now get the error "The system cannot find the specified file" (C:\WINNT\System32\javac.exe)
So, if I compile from the command line it works. If I compile using TextPad, it doesn't. I can run the application with TextPad, but just can't compile. I guess I'll just have to compile from the command line.
Maybe I should uninstall and re-install TextPad. Maybe that will help???
Thanks for you suggestions Frank!
Brian
19 years ago
I have some classes that had compiled and backed up before I installed NT. After the installation of NT, I restored my old Java directory that had all of my classes in them. I am able to run the java program and execute my existing classes just fine.
But, if I try to compile one of those existing programs I get the error I mentioned above. I also get it if I just type javac at the command line with no arguments.
The only thing I have done that I can think of that may have caused a problem is I installed IBM's ViaVoice SDK to start working on some speech recognition with the Java Speech API. This installation tries to install the jdk1.3, if it's not already installed. I had it installed prior to this installation. I noticed that the IBM software made some entries in the PATH variable, but I'm not sure if that would cause this problem.
Thanks for your reply,
Brian
19 years ago
I just installed NT and copied my jdk1.3 directory from another machine to a new drive on my NT machine. I set the PATH variable to E:\jdk1.3\bin but when I try to compile a class I am getting this exception.
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/javac/Main
Any ideas as to what I have done wrong?
Thanks,
Brian
19 years ago
As you suggested, there are several approaches to this assignment. I am still working on my third submission, and will probably have more. Paul Wheaton made a good suggestion in another message that really helped me.
He said...

For some cattle drive folks I add the requirement that I want them to make a method that introduces some abstraction. The method will take and integer and the value must be in the range of 0 to 999. It will then "say" that value.
If you have such a method, writing your main becomes much easier. From within this new method, your task becomes much easier. The whole program falls together.


He's right, once you have done this the program seems to be much easier to write and you can easily add other methods to handle the larger numbers.
One other side note, don't forget about negative numbers!
Brian
19 years ago
I have just submitted my second version of assignment 1.4 and I have never had a problem with delays in getting responses back from the nit-picker within a day or two at the most.
I understand that this site is starting to get more and more popular, with good reason. Most of the people working this site, if not all, I'm sure have other jobs too and are doing all of us a great service by helping in the ways they do, especially Marilyn. I don't mind waiting, I'm greatful that you are able to help as much as you do.
19 years ago