3 Replies Latest reply: Jun 7, 2009 11:03 PM by EJP RSS

    Writing to a file

    807588
      This code has no errors yet does nothing even with an arraylist with size 1
      public void write(ArrayList<Rthing> input) {
              FileWriter writer;
              try {
                  writer = new FileWriter(x);
                  BufferedWriter output = new BufferedWriter(writer);
                  if (input.size() == 0) {
                      output.write("0");
                      output.newLine();
                  } else if (input.size() > 0) {
                      String secondInt1 = Integer.toString(input.size());
                      output.write(secondInt1);
                      output.newLine();
                      for (int i = 0; i < input.size() - 1; i++) {
                          Rthing o;
                          o = input.get(i);
                          for (int s = 0; s < 5; s++) {
                              ArrayList<String> stringlist = o.StoArrayL();
                              output.write(stringlist.get(s));
                              output.newLine();
                          }
                          for (int y = 0; y < 10; y++) {
                              ArrayList<Integer> intlist = o.ItoArrayL();
                              String secondInt = Integer.toString(intlist.get(y));
                              output.write(secondInt);
                              output.newLine();
                          }
                          String secondDouble = Double.toString(o.getPhone());
                          output.write(secondDouble);
                          output.newLine();
                      }
                  }
                  output.close();
              } catch (IOException ex) {
                  System.out.println("It Failed Again");
              }
          }