-
February 13th, 2014, 12:22 AM
#1
Block division
I'm having a file with binary Unicode (mean file contain Unicode value of corresponding data (text file)), want to divide that as blocks with the size of 144bits. I don't know how to code for this so please kindly help me.
-
February 13th, 2014, 08:46 AM
#2
Re: Block division
What have you tried?
Can you read the file as bytes: 144/8 at a time?
Norm
-
February 16th, 2014, 09:33 AM
#3
Re: Block division
Of course, we can read it as bytes too.So we will get 18 bytes. Can you please help me in that coding for block division?
-
February 16th, 2014, 09:37 AM
#4
Re: Block division
What have you tried? The FileInputStream class has method for reading bytes.
Norm
-
February 21st, 2014, 12:43 AM
#5
Re: Block division
I have used FileInputStream class but its not working properly to divide the bits into blocks.I will attach the coding,help me out to fix the problem.
public static void main(String[] args) {
ReadFileExample newclass = new ReadFileExample();
System.out.println("cryptography");
File input = new File("D:/java/source.txt");
File output = new File("D:/java/target.txt");
byte[] block = new byte[18];
try {
FileInputStream fis = new FileInputStream(input);
FileOutputStream fos = new FileOutputStream(output);
//CipherOutputStream cos = new CipherOutputStream(fos);
System.out.println("Total file size to read (in bytes) : "
+ fis.length());
int i;
while ((i = fis.read(byte[18]))!= -1) {
System.out.println(block);
fos.write(block, 0, i);
}
fos.close();
}
catch (Exception e)
{
System.out.println("invalid");
}
}}
-
February 21st, 2014, 07:08 AM
#6
Re: Block division
Please edit the post and wrap the code in code tags to make it easier to read.
can you explain what that means? If there are errors, please copy the full text and paste it here.
Also posted at: http://www.javaprogrammingforums.com...ptography.html
Last edited by Norm; February 21st, 2014 at 07:14 AM.
Norm
-
February 21st, 2014, 09:41 AM
#7
Re: Block division
The error is that the code could not block divide the bits. It just reads the bits from the input file and writes the same as it is to the input text file without dividing them into blocks. Error appears in the 'while loop' too. What's wrong in that?
-
February 21st, 2014, 09:55 AM
#8
Re: Block division
Please copy the full text of the error message and paste it here. You need to fix the error before you can test the code.
Please edit your post and wrap your code with code tags:
[code]
YOUR CODE HERE
[/code]
to get highlighting and preserve formatting.
Norm
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|