Sunday Feb 05
Move
Display 0 | 5 | 10 | 15 Stories

Programming

Topics
Top Story

Code for Writing a xlsx file in java

Here is a small code to write xlsx file though java code.    You may need to include some of...

Code for Reading a xlsx file in java

Here is a small code to read xlsx file thoug java code.    You may need to include some of the...

How to read and write data from socket in java

   ServerSocket serverSocket=new ServerSocket(port);  // The below statement will wait for the...

Producer Consumer Problem in C using Semaphores and Shared Memory

  The classic bounded-buffer problem can be implemented using a variety of synchronization mechanisms....

Common Intermediate Language

Common Intermediate Language (formerly called Microsoft Intermediate Language or MSIL) is the lowest-level...

Common Type System in C#

Common Language Runtime

A Quick Introduction to C# Features

Code for updating database using hibernate framework in java

Conversion of int to byte and vice versa

Web Crawler in Python

Neural Network in Python

Programming

Conversion of int to byte and vice versa

(0 votes, average: 0 out of 5)





The below function is to convert an int to byte. You have to pass a int value and receive the byte in a byte array
 
 
public byte[] ToByte(int a) throws IOException
{
ByteArrayOutputStream bos=new ByteArrayOutputStream();
                DataOutputStream dos=new DataOutputStream(bos);
                dos.writeInt(a);
                dos.flush();
                byte[] b1=bos.toByteArray();
                return b1;
        }
 
 The below function is to convert an byte to int. You have to pass a byte array and receive the int value
 
One int value = 4 byte as int size is 4 byte
 
public int ToInt(byte[] b) throws IOException
{
ByteArrayInputStream bis=new ByteArrayInputStream(b);
                DataInputStream in=new DataInputStream(bis);
                int a=in.readInt();
                return a;
        }
 
 


Add this page to your favorite Social Bookmarking websites
Reddit! Del.icio.us! Google! Live! Facebook! Slashdot! Technorati! StumbleUpon! Spurl! Furl! Yahoo! Squidoo! Ask! DZone! Free Joomla PHP extensions, software, information and tutorials.



Comments

B
i
u
Quote
Code
List
List item
URL
Name *
Code   
ChronoComments by Joomla Professional Solutions
Submit Comment

Tag Cloud

Login Form