PrintWriter exception: String index out of range?

I think you've misunderstood the definition of PrintWriter. Write(string,offset,length). If I read your question correctly, you think it will write into the output file at that offset.

However, the offset specifies where in the string being written to start, so you're trying to write from the string "ok" starting at offset 23. Since the string only has 2 characters you get the exception.

I think you've misunderstood the definition of PrintWriter. Write(string,offset,length). If I read your question correctly, you think it will write into the output file at that offset.

However, the offset specifies where in the string being written to start, so you're trying to write from the string "ok" starting at offset 23. Since the string only has 2 characters you get the exception. Take a look at java.io.

RandomAccessFile if you really want to overwrite specific bytes in a file. Note that, while you can overwrite specific bytes in a file with other bytes, you cannot "insert" data or delete data from a file (resulting in a file of different length) without reading it into memory and writing a new copy to disk.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions