This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Java in General and the fly likes Splitting a string - Different behavior between win xp and linux Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Splitting a string - Different behavior between win xp and linux " Watch "Splitting a string - Different behavior between win xp and linux " New topic
Author

Splitting a string - Different behavior between win xp and linux

Rob Page
Greenhorn

Joined: Dec 01, 2010
Posts: 4
Hi, and (anyway) thanks for your time.
Maybe I'm not completely seeing what's going on in my sw because I obtain a different behavior from the same method running in two different machines: first one w/ win xp and the second w/ linux (CentOS).
My method has to split a string like the following:

"2010-08-11 16:55:15,336 123.123.123.123 "Mozilla/5.0 (iPad; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Release/3.0/12345 asdfghjklpoiu-123" abc 12345678"

I use a regex like this: "\\x20{2,}" in order to obtain tokens that are separated by 2 or more spaces.

Deployed on win xp it works, on linux not (same JVM).

Have you any suggestion.
Again thank you for your time.

Rob

Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14192
    
  20

Welcome to JavaRanch.

What exactly do you mean with "it works / it doesn't work"? What is exactly the output that you expect, and what happens in reality - and how do these two differ? Can you show us the source code and the exact difference between the outputs on the two OSes?


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Rob Page
Greenhorn

Joined: Dec 01, 2010
Posts: 4
Sorry for my poor description of the problem...
This is the code, I implemented a handler compliant with the architecture of Apache-MINA receivers:



On win xp I obtain:

splitString[0] = "2010-08-11"
splitString[1] = "16:55:15,336"
splitString[2] = "123.123.123.123"
splitString[3] = "'Mozilla/5.0 (iPad; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Release/3.0/12345 asdfghjklpoiu-123'"
splitString[4] = "abc"
splitString[5] = "1234567"

On linux I obtain that the whole string is put in splitString[0]
Thanks

Rob
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

Are you sure the input string is exactly the same? Is it perhaps not missing spaces that are sent in Windows, so there are no occurrences of 2 or more spaces?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rob Page
Greenhorn

Joined: Dec 01, 2010
Posts: 4
Rob Prime wrote:Are you sure the input string is exactly the same? Is it perhaps not missing spaces that are sent in Windows, so there are no occurrences of 2 or more spaces?


Yes, I'm sure
 
GeeCON Prague 2014
 
subject: Splitting a string - Different behavior between win xp and linux