This week's book giveaway is in the Testing forum.
We're giving away four copies of Data Structures the Fun Way: An Amusing Adventure with Coffee-Filled Examples and have Jeremy Kubica on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Compartor not working correctly in Windows Server 2012

 
Bartender
Posts: 1899
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a basic file comparator that works correctly in Windows 2003 Server, but does not work correctly in Windows 2012 Server:


.
.
.


The latest file is not correctly sorted.

Any obvious reasons for this difference?

Thanks,

-mike
 
Sheriff
Posts: 22701
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mike London wrote:


That's probably the cause. When you truncate the last modification timestamps, you lose information. Those ints may very well be negative. Use Long.compare instead:
The static compare methods have been added in Java 7 to all of the primitive wrappers (including Boolean). There is no need to box primitives anymore.
 
Mike London
Bartender
Posts: 1899
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:

Mike London wrote:


That's probably the cause. When you truncate the last modification timestamps, you lose information. Those ints may very well be negative. Use Long.compare instead:
The static compare methods have been added in Java 7 to all of the primitive wrappers (including Boolean). There is no need to box primitives anymore.



Yes, it was old code, thanks!

My issue appeared to be that in the old code, possibly due to the issue you raised, I was taking the last value in the list, which works on Windows 2003 server and earlier versions of the JDK. However, in Java 8 and Windows 2012 server (assuming Windows has nothing to actually do with any of this), I need the top value on the sorted list.

However, I get the same results with the old code and the new (your) code.

In any case, I've simplified that ugly boxing from the old code and made it much cleaner looking.

Thanks!!!

- mike
 
Rob Spoor
Sheriff
Posts: 22701
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome.
 
And will you succeed? Yes you will indeed! (98 and 3/4 % guaranteed) - Seuss. tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic