Adding characters to beginning and end of InputStream in Java
I have an InputStream which I need to add characters to the beginning and end of, and should end up with another variable of type InputStream . How could I easily do this? You want a SequenceInputStream and a couple of ByteArrayInputStream s. You can use String.getBytes to make the bytes for the latter. SequenceInputStream is ancient, so it's a little clunky to use: InputStream middle ; String beginning = "Once upon a time ...\n"; String end = "\n... and they lived happily ever after."; List<InputStream> streams = Arrays.asList( new ByteArrayInputStream(beginning.getBytes()), middle, new