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); 
  • * readBytes () method - Shanti
  • try 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
  • @zRrr, thanks, helped)) - Shanti
  • @zRrr plus my error in the for line (int i = 0; i <dis.available (); i ++). dis.available () - decreases with each iteration .. the part of the bytes just did not read .. - Shanti

0