File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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: 14146
    
  18

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 7 API documentation
Scala Notes - My blog about Scala
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: 19693
    
  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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Splitting a string - Different behavior between win xp and linux