• Post Reply Bookmark Topic Watch Topic
  • New Topic

pipe data through stdout in windows.

 
Chris Stones
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have been googleing all day and this is driving me mad!!!
program2 processes data from program1 in the usual *nix way.

program1 < input.bin | program2 > output.bin

no problem in Unix.
in win32, stdin / stdout are not binary, but foratted text, ( replaces \n with \r\n etc etc ANNOYING )

in c, i would normally use freopen in win32 to set stdin / stdout to binary mode.

How can i accumplish this in java ?

I am using System.out and System.in to read / write serializable objects.
XML serialization is not optional, as i dont want to make my objects beans compliant, and i dont want to intorduce xstream as a dependancy... also performance is quite important, so binary serialisation is the way to go.

Is this possible ???

THANKS.

 
Carey Brown
Bartender
Posts: 2257
28
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting question. I'm curious to see other responses you get. Off hand I'd say to use base64 encoding, that would eliminate the carriage-return issue and the object IO issue but does have some performance hit. Also program 1 & 2 would have to agree to talk using this format. There are lots of base64 java libraries out there, Apache.Commons has one.
 
Chris Stones
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
confused!!!

decided to *just try it anyway(tm)*
and everyhing seems to be working fine !

perhaps sun anticipated my needs, and implemented the binary serialization algorithm to work around
win32 annoyances, or perhaps the vm sets stdin / stdout binary on startup.

not sure how this is working, but it is !
 
Paul Clapham
Sheriff
Posts: 21892
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There ya go... the answer to "Will this work?" is generally "What happened when you tried it?". Especially when it costs very little to try it. Thanks for the feedback, it might be useful for someone else in the future.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!