-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBitWork.java
More file actions
executable file
·52 lines (50 loc) · 1.68 KB
/
BitWork.java
File metadata and controls
executable file
·52 lines (50 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package miniproject;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
/**
*
* @author gunner
*/
public class BitWork {
public void byteToBit(String s2) throws FileNotFoundException, IOException
{
FileInputStream fileInputStream = null;
FileOutputStream fileOutputStream = null;
File file1=new File(s2);
fileInputStream = new FileInputStream(s2);
fileOutputStream= new FileOutputStream("actdata2.txt");
byte b[];
b=new byte[(int)file1.length()];
fileInputStream.read(b);
byte b1=(byte)0;
int j=0;
for(int i=0;i<file1.length();i++)
{
j++;
b1=(byte)(b1<<1);
if(b[i]!=0)
{
b1=(byte)(b1+1);
}
if(j==7)
{
fileOutputStream.write(b1);
//System.out.print(" "+b1);
j=0;
b1=(byte)0;
}
}
fileOutputStream.close();
Compress c2=new Compress();
String s3="C:\\Users\\gunner\\Documents\\NetBeansProjects\\Miniproject\\actdata2.txt";
c2.data2comp();
}//function which converts binary data into bit.
}