Good day! The task is given: you need to encrypt the text from the file (there are no questions here), BUT how to perform character-by-character reading from the file so that I can manipulate these characters in my array (assign a character with a specific index, etc.).
Suppose I read a part of the text, process it - write it into an array, write the contents of the array (modified text) into another file.
And you need to know the length of the entire source text.
Tell me, please, because I am confused with various FileInput-OutputStream, FileRider / Writer, StringBuffer / Builder.
Yes, I also have KOI8-U (Ukrainian) encoding, I tried to output it through:
public static String loadFileAsString(File file, String encoding) throws IOException { InputStreamReader f= (encoding==null ? new FileReader(file):new InputStreamReader( new FileInputStream(file),encoding)); StringBuffer sb= new StringBuffer(); try { char[] buf= new char[1000]; int len; while ((len=f.read(buf,0,buf.length))>=0) { sb.append(buf,0,len); } return sb.toString(); }catch(FileNotFoundException ex) { System.out.println("FileNotFoundException: " + file + " exc: " + ex); } finally { try {f.close();} catch (Exception e) {}; } return null; }
as stated in http://www.cyberforum.ru/java-j2se/thread156012.html is nonsense, so there is no need to encrypt)).
So really need help!