Плиз помогите розобрать что делает код
Код | package javaapplication2;
import javax.swing.*; import java.io.File; import java.io.RandomAccessFile;
/** * Created by I0_Bit on 12.11.2015. */ public class JavaApplication2 { public static void main(String[] args) { byte n[] = new byte[8]; int c = 11; n[0]=1; n[1]=2; for (int i = 2; i < 8; i++) { n[i] =( byte)( (n[i-1] + n[i-2]) % c); // System.out.print(n[i]+" "); }
int replace[] = {n[0], n[1], n[2], n[3], 10010010, 01001001, 00100100, 01001001, 00100100, 10010010,00100100, 10010010, 01001001, 00000000, 00000000, 00000000 , 00110011, 00110011, 00110011, 01100110, 01100110, 01100110, 10011001, 10011001, 10011001 , 11001100, 11001100, 11001100 , 11111111, 11111111, 11111111 , 10010010, 01001001, 00100100 , 01001001, 00100100, 10010010 , 00100100, 10010010, 01001001 , 01101101, 10110110, 11011011 , 10110110, 11011011, 01101101 , 11011011, 01101101, 10110110 , n[4], n[5], n[6], n[7]};
byte b1=0; byte b2[] = new byte[3];
try { JFileChooser dialog = new JFileChooser(); dialog.showOpenDialog(dialog); File file1 = dialog.getSelectedFile();
RandomAccessFile file = new RandomAccessFile(file1, "rw");
long count = file1.length(); for(;count%3!=0;count++) {
} System.out.println("Total found = " + count + " characters!");
for (int i = 0; i < 41; i++) { long ptr = 0; if (i <=3 || (i >=13 && i <=18) || i >=37) { b1 = (byte) replace[i]; } else {
for (int j = 0; j < 3; j++) { b2[j] = (byte) replace[i++]; } }
for (ptr=0; ptr < count;) { if (i <=3 || (i >=13 && i <=18) || i >=37) { //file.seek(ptr); file.writeByte(b1); ptr++;// = file.getFilePointer();
} else {
file.writeByte(b2[0]); file.writeByte(b2[1]); file.writeByte(b2[2]); ptr=ptr+3;
}
} file.seek(0); } file.close(); // file1.delete(); } catch (Exception ex) { String error = ex.toString(); System.out.println(error); } } }
|
|