It is necessary to read less than 8 bytes from the x.txt file (incomplete long) and write them sequentially to long T, the rest of T is filled with zeros. I read it, I wrote it down, and in the output file, it was not clear where the bits were taken from ...
FileInputStream inputFile = new FileInputStream("x.txt"); FileOutputStream outputFile = new FileOutputStream("y.txt"); DataInputStream dis = new DataInputStream(inputFile); DataOutputStream dos = new DataOutputStream(outputFile); long T = 0; //ΡΠ΄Π²ΠΈΠ³Π°Π΅ΠΌ ΠΊΠ°ΠΆΠ΄ΡΠΉ Π±Π°ΠΉΡ ΠΊ "ΡΠ²ΠΎΠ΅ΠΌΡ" ΠΌΠ΅ΡΡΡ Π² Π’ for (int i = 0; i < dis.available(); i++) { T += (long)(dis.readByte()) << (7 - i)*8; } dos.writeLong(T);
T += (readByte() & 0xFFL) << (7 - i)*8;, in java bytes - a sign, when expanding to a long "negative byte", the high-order bits are achieved in units. - zRrr