Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

how to change my file into binary data using java

File file = new File("filename.bin");
byte[] fileData = new byte[file.length()];
FileInputStream in = new FileInputStream(file);
in.read(fileData):
in.close();
// now fileData contains the bytes of the file
Comment

how to change my file into binary data using java

String content = "";
for(byte b : fileData)
    content += getBits(b);
// content now contains your bits.
Comment

how to change my file into binary data using java

String getBits(byte b)
{
    String result = "";
    for(int i = 0; i < 8; i++)
        result += (b & (1 << i)) == 0 ? "0" : "1";
    return result;
}
Comment

PREVIOUS NEXT
Code Example
Java :: Leap year or not program in java using if-else 
Java :: postfix operator in java 
Java :: ArrayIndexOutOfBoundsException 
Java :: Java Enum ordinal() 
Java :: java random value threadlocalrandom 
Java :: my animal list 
Java :: Add an instance variable of type Safe to the class Room. This instance variable should be initialised in the constructor of Room, and an appropriate query should be defined to get it. 
Java :: java non-breajubg soace remove 
Java :: spring amqp exchange not found 
Java :: bootstrap messages red 
Sql :: sql server search column name in all tables 
Sql :: alter session set nls_date_format 
Sql :: mysql list bigger table 
Sql :: alter table add column boolean 
Sql :: postgresql server restart 
Sql :: check database name oracle 
Sql :: oracle list columns 
Sql :: postgresql list extensions 
Sql :: mysql unix timestamp to date 
Sql :: postgres alter user password 
Sql :: show max_allowed_packet mysql 
Sql :: sql add date hour 
Sql :: raise application error in oracle 
Sql :: configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path 
Sql :: not today mysql 
Sql :: dbms_scheduler stop job 
Sql :: sqlite connection string 
Sql :: ORA-01950 
Sql :: get count by weekly pivot table sql server 
Sql :: Error Code: 1055. Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =