public static void main(String[] args) throws IOException {
   FileConsoleWriter fileConsoleWriter = new FileConsoleWriter("jan");
   fileConsoleWriter.write("Проверка String:");
   fileConsoleWriter.write(1234);
   char[] buff = "Проверка char buff:".toCharArray();
   fileConsoleWriter.write(buff);
   fileConsoleWriter.write(buff, 3, 5);
   fileConsoleWriter.write("Проверка String обрезка:", 0, 2);
   fileConsoleWriter.flush();
   fileConsoleWriter.close();
 }
Example #2
0
  public static void main(String[] args) throws IOException {
    String fileName = "C:\\Users\\Sandark\\Documents\\result.txt";

    String text = "Юные археологи\r\nПытаются свести\r\nСвои счета на Родине\r\nНа Родине отцов";
    int nine = 9;
    char[] array = text.toCharArray();
    String arrayString = array.toString();
    FileConsoleWriter writer = new FileConsoleWriter(fileName);

    writer.write(text);
    writer.write(nine);
    writer.write(array);

    writer.close();
  }
 public void write(int c) throws IOException {
   if (writeBuffer == null) {
     writeBuffer = new char[writeBufferSize];
   }
   writeBuffer[0] = (char) c;
   write(writeBuffer, 0, 1);
 }
 public void write(String str, int off, int len) throws IOException {
   char cbuf[];
   if (len <= writeBufferSize) {
     if (writeBuffer == null) {
       writeBuffer = new char[writeBufferSize];
     }
     cbuf = writeBuffer;
   } else {
     cbuf = new char[len];
   }
   str.getChars(off, (off + len), cbuf, 0);
   write(cbuf, 0, len);
 }
 @Override
 public void write(String str, int off, int len) throws IOException {
   write(str.toCharArray(), off, len);
   super.write(str, off, len);
 }
 @Override
 public void write(String str) throws IOException {
   write(str.toCharArray(), 0, str.length());
 }
 @Override
 public void write(char[] cbuf) throws IOException {
   write(cbuf, 0, cbuf.length);
 }
 @Override
 public void write(int c) throws IOException {
   char[] var2 = new char[] {(char) c};
   write((char[]) var2, 0, 1);
 }
 public void write(String str) throws IOException {
   write(str, 0, str.length());
 }