а
package com.javarush.task.pro.task15.task1532;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Arrays;
/*
Шифр
*/
public class Solution {
public static void main(String[] args) {
System.out.println(encrypt("abcdefghi"));
}
public static ByteArrayOutputStream encrypt(String message) {
var byteMessage = message.getBytes();
try(ByteArrayOutputStream output = new ByteArrayOutputStream()) {
for (int i = 0 ; i < message.length() / 2 + message.length() % 2; i++) {
output.write(byteMessage[i]);
output.write(byteMessage[message.length() - i - 1]);
}
return output;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}