Help coderanch get a
new server
by contributing to the fundraiser

Rob MacKay

Ranch Hand
+ Follow
since Apr 06, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Rob MacKay

Mods can delete this post if they want. I've found a good solution here:

http://cnx.org/content/m37101/latest/
10 years ago
Pretty straightforward question...

Writing in .NET (vb to be more precise)

How do I create a thread and have it do nothing except wait to receive an event notification, at which point some code gets executed and once the code is complete, the thread goes idle again and waits for the next notification?

I've found that if you create and start a thread that doesn't do anything, it just starts, stops and is gone.

Thanks in advance
10 years ago
FYI - this worked quite well. Thanks for the idea.
Thanks. This looks like it could be quite useful, especially if the Apache FTP jars, etc can be converted to DLLs for use in .NET. Would that be possible?
Not sure if this is the write forum for this question. Hopefully I'm close.

I've written a nice custom ftp server in Java using Apache that works marvelously. Unfortunately, I've been told that it needs to be re-written in VB or C# (aka .net) for windows and NOT use IIS for the FTP api. So.... Is there a suitable .net equivalent to Apache?

Thanks
Seems like the best way is to use a simple % calculation of the long total value vs the current value and then call the setString method on the progress bar.
11 years ago
I am using a JProgressBar to represent the total number of bytes being downloaded when grabbing multiple files from a server.

However, during the calculation of the total number of bytes, which is what I use for the max value of the JProgressBar, the value goes outside the range of the 'int' datatype, which will wrap around and possibly give a negative number, breaking the JProgressBar or at the very least, providing an inaccurate value.

What's the best way to solve this problem of the max range being too high?

Should I just covert my bytes to megabytes, which will lose a bit of precision in the progress calculation? Or, if I want to keep the precision of number of downloaded bytes vs the total number to download, how can I get an accurate % to display in the JProgressBar using the long values?



11 years ago

Paul Clapham wrote:But the bottom line is... it's still broken and needs to be fixed, right? The workaround appears to be "Run under Java 1.6".



Correct since I doubt it would be a good idea to grab the old classes from the 1.6 rt.jar file and stuff them in a patch.jar and use it in the classpath. :)
12 years ago

Paul Clapham wrote:I believe that all of your questions (except perhaps the last one) are covered here: Why Developers Should Not Write Programs That Call 'sun' Packages.



LOL.. unfortunately this isn't code I've written, just code I am using. :(

Of course - the "sun" package name hasn't changed here, just the actual class name.
12 years ago
I have some code that compiles fine under 1.6 but does not under 1.7.

During troubleshooting, I notice that in 1.7, the class sun.beans.editors.BoolEditor is now called BooleanEditor. There are no references to the old class name.

Isn't this a break of backwards compatibility at a rather simple level?

Is this something known to Oracle that may be fixed in the future?

What's the best way to work around this incompatibility?

12 years ago

Greg Charles wrote:Maybe Windows is just having a bad day. It certainly seems to prevent me from deleting files that I know no process is touching.



Agreed. I can't say that haven't had that happen before.

I think I narrowed it down a bit though and it seems that I can detect locks on the executable itself (which I wasn't checking before), just not the jar files it may have loaded, which is what Windows wouldn't let me touch. The problem is that I want to modify / replace that jar file and wanted to be able to detect the scenario where it was in use.
12 years ago
Hello,

I have a routine in my application that tests to see if a given file is locked. This file belongs to another java application written by someone else in my organization and I have no idea if they are doing anything to correctly lock the file. However, on windows, when the other application is running, I am prevented from deleting the file using windows explorer. Given that bit of logic, one would assume that my tryLock method call should not be returning me an exclusive lock, which it in fact does.

Any idea why I would be able to get an exclusive lock on a file that, from the outside, appears to already be locked by the other running application?

Note - the other application is running in a completely separate VM.

Have I provided enough information? The method for getting the lock is quite standard that you see on most every other file lock question.
12 years ago
Correct. Basically looking for a word wrapping utility that can take a parameter for the number of characters per line and then adjust accordingly.
12 years ago
I have a use case where I need to read a text file read a text file (possibly quite a large one) into an InputStream and then display the contents to the System.out.

Simple enough, I am using the 1.6 Console class to access it's, which is pretty much -> PrintWriter.println(mytext). This works fine, except that the entire contents are just dumped to the screen, which is pretty silly for a very large text file since there would be no way to read it all.

What I want to be able to do is limit the amount of the text file getting dumped to the screen so that the user can read it and effectively "click" through it by hitting enter or any other key. Basically, paging through the text until it's all written to the screen.

Are they any handy algorithms around that can format the large String into something that PrintWriter can handle in this way?

I have a few ideas but don't want to re-invent the wheel.
12 years ago

Mike Simmons wrote:
This seems problematic. I have Effective Java right here, and can't find any HashCodeUtil - where does this come from? The hashing techniques in Effective Java do not in general guarantee uniqueness - they just make it statistically very likely.



Sorry - it's based on the techniques in Effective Java. An example is here:

http://www.javapractices.com/topic/TopicAction.do?Id=28

12 years ago