public byte[] ToByteArray() throws IOException { byte[] BA; byte[] B1A = new byte[1]; byte[] Int64Space = new byte[4]; ByteArrayOutputStream BOS = new ByteArrayOutputStream(1024); try { BA = TDataConverter.ConvertInt32ToLEByteArray(ID); BOS.write(BA); BOS.write(Int64Space); // . BA = TDataConverter.ConvertInt16ToLEByteArray(Level); BOS.write(BA); // . BA = TDataConverter.ConvertInt16ToLEByteArray(InfoComponent_Type); BOS.write(BA); // . BA = TDataConverter.ConvertInt32ToLEByteArray(InfoComponent_ID); BOS.write(BA); BOS.write(Int64Space); // . BA = TDataConverter.ConvertDoubleToLEByteArray(BindingPointX); BOS.write(BA); // . BA = TDataConverter.ConvertDoubleToLEByteArray(BindingPointY); BOS.write(BA); // . BA = TDataConverter.ConvertDoubleToLEByteArray(BaseSquare); BOS.write(BA); // . BA = TDataConverter.ConvertInt32ToLEByteArray(InfoImageDATAFileID); BOS.write(BA); BOS.write(Int64Space); // . B1A[0] = (byte) InfoString.length(); BOS.write(B1A); if (B1A[0] > 0) BOS.write(InfoString.getBytes("windows-1251")); // . BA = TDataConverter.ConvertInt32ToLEByteArray(InfoStringFontColor); BOS.write(BA); // . B1A[0] = InfoStringFontSize; BOS.write(B1A); // . B1A[0] = (byte) InfoStringFontName.length(); BOS.write(B1A); if (B1A[0] > 0) BOS.write(InfoStringFontName.getBytes("windows-1251")); // . return BOS.toByteArray(); } finally { BOS.close(); } }
public synchronized void SaveItems() throws IOException { FileOutputStream FOS = new FileOutputStream(HintsFileName); try { byte[] ItemsCountBA = TDataConverter.ConvertInt32ToLEByteArray(ItemsCount); FOS.write(ItemsCountBA); TSpaceHint Item = Items; while (Item != null) { byte[] BA = Item.ToByteArray(); short ItemDataSize = (short) BA.length; byte[] ItemDataSizeBA = TDataConverter.ConvertInt16ToLEByteArray(ItemDataSize); FOS.write(ItemDataSizeBA); FOS.write(BA); // . Item = Item.Next; } } finally { FOS.close(); } }