Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: java equivalent of the following c# code

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default java equivalent of the following c# code

    How would I do the following in Java?

    sw.Write(Convert.ToInt16(100));

    I've tried:
    sw.writeShort(100);

    But it seems to order the bits wrong.

    Thanks,
    Scott


  2. #2
    Member
    Join Date
    Mar 2012
    Location
    United States
    Posts
    118
    My Mood
    Inspired
    Thanks
    1
    Thanked 33 Times in 31 Posts

    Default Re: java equivalent of the following c# code

    I am guessing you are using the StreamWriter class in C#, what class have you chosen to use in your Java code?

  3. #3
    Junior Member
    Join Date
    Apr 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: java equivalent of the following c# code

    Quote Originally Posted by KucerakJM View Post
    I am guessing you are using the StreamWriter class in C#, what class have you chosen to use in your Java code?
    Actually I got it work.

    sw.writeShort(Short.reverseBytes( (

    short ) 100)); //id

    Thanks!

Similar Threads

  1. problem in my code java code graph editeur
    By kisokiso in forum Java Theory & Questions
    Replies: 5
    Last Post: January 6th, 2012, 08:36 AM
  2. Replies: 3
    Last Post: September 8th, 2011, 02:25 PM
  3. Replies: 10
    Last Post: April 5th, 2011, 09:09 AM
  4. KeyStore.getInstance("Windows-MY") : Equivalent on Linux plateform ?
    By Nicolas74100 in forum Java Theory & Questions
    Replies: 1
    Last Post: November 14th, 2010, 03:49 PM
  5. Java equivalent of Python’s struct.pack?
    By thiruvadi.e in forum Java SE APIs
    Replies: 2
    Last Post: July 14th, 2010, 03:09 AM