title: second buffered writer won't work
body: <p>I have a little problem with my simple I/O inventory program. It's a program that writes the output that the user entered into a text file that serves as an "inventory". I was able to do it. However, when I tried to create and append on a different text file on the same file folder, it wouldn't write the input into the new text file. I know I really lack the experience to explain properly my concern. But I'm trying my best though, so basically, I would just like to print the information I entered as "sales" into the second text.file on the same path folder. I hope you can get some ideas if you check and run my code. The code is working but, like I said, the only problem is the input/output on a different text file. I would really appreciate your help. Thanks.</p>
  
  <p>Carl</p>
  
  <p>Here's my code:</p>
  
  <pre><code>   import java.io.BufferedOutputStream;
      import java.io.BufferedWriter;
      import java.io.IOException;
      import java.io.OutputStream;
      import java.io.OutputStreamWriter;
      import java.nio.file.Files;
      import java.nio.file.Path;
      import java.nio.file.Paths;
      import java.nio.file.*;
  
      import static java.nio.file.StandardOpenOption.*;
  
      import java.text.*;
      import java.util.*;
  
      public class Inventorypos {
  
          public static void main(String[]args) {
  
              Scanner input = new Scanner(System.in);
              String File ="D:\\Copro2\\Inventory.txt";
              String File2 ="D:\\Copro2\\Sales.txt";
  
              Path file = Paths.get("D:\\Copro2\\Inventory.txt");
              Path salefile = Paths.get("D:\\Copro2\\Sales.txt");
  
  
              String st = " ";
              String sH = " ";
              String sF = " ";
              String sS = " ";
              String delimeter = "................ ";
              int itemnum;
              int itemname;
              String H="Hamburger";
              String F="French Fries";
              String S="Softdrinks";
              int menu;
              long menu2 = 0;
              final long QUIT = 5;{
  
  
          {
  
  
          try{
  
              Runtime rt=Runtime.getRuntime();
  
              OutputStream invent = new BufferedOutputStream(Files.newOutputStream(file, CREATE));
                      BufferedWriter writer = new
                  BufferedWriter(new OutputStreamWriter(invent));
  
  //so here is my problem here, I couldn't make this work
  
              OutputStream sale = new BufferedOutputStream(Files.newOutputStream(salefile, CREATE,StandardOpenOption.APPEND));
                      BufferedWriter writer2 = new
                  BufferedWriter(new OutputStreamWriter(sale));
  
  
                      String sa= "---- Sales ----";
                      writer2.write(sa);
                      writer2.newLine();
  
  
  
  
                      String in= "---- Inventory ----";
                      writer.write(in);
                      writer.newLine();
  
  
  
                      System.out.println("---- Page Menu ----");
                      System.out.println("1. Add Inventory \n2. Sell \n3. View Inventory \n4. View Sales \n5. Exit ");
                      System.out.print("Enter selection: ");          
                      menu= input.nextInt();
  
                      while(menu2 != QUIT){
  
  
  
                      if(menu==1) {
                          System.out.println("Add Inventory: " );
                          System.out.print("1.) Hamburger \n2.)French Fries \n3.)Softdrinks\n");
                          System.out.println("Enter Item: " );
                          itemname= input.nextInt();
  
  
                          if (itemname == 1){
                              System.out.print("How many do you want to store? ");
                              itemnum = input.nextInt();  
  
                          sH = H + delimeter + itemnum;
  
                          writer.write(sH, 0, sH.length());
                          writer.newLine();
                          }
                          else if (itemname == 2){
                              System.out.print("How many do you want to store? ");
                              itemnum = input.nextInt();  
                              sF = F + delimeter + itemnum;
  
                              writer.write(sF, 0, sF.length());
                              writer.newLine();
                          }
                          else if (itemname == 3){
                              System.out.print("How many do you want to store? ");
                              itemnum = input.nextInt();  
                              sS = S + delimeter + itemnum;
  
                              writer.write(sS, 0, sS.length());
                              writer.newLine();
  
                          }
                          else{
                              System.out.println("Invalid input!");
                              menu=1;
                          }
                          System.out.print("Enter 1 to store another item, 2 to view inventory, 3 sell,4 to quit: ");
                          menu2 = input.nextLong();       
                          if (menu2==1){
                               menu=1;
  
                          }
                          else if (menu2==2){
                              menu=3;
                          }
                          else if (menu2==3){
                               menu=6;
                          }
                          else if (menu2==4){
                               menu2=QUIT;
                          }
                          else{
                              System.out.println("Invalid Input!");
                          }
  
  
                      }
                  if(menu==2){
  
  
  
                          System.out.print("---- Food Menu ----");
                          System.out.println("\n1.) Hamburger P25 \n2.) French Fries P25 \n3.) Softdrinks P25");
                          System.out.println("Enter your order: ");
                          int ord = input.nextInt();
  
  
  
                          if (ord==1){
  
                              System.out.println("How many?");
                              int hm = input.nextInt();
                              int totph = hm*25;
  
                              /*String intwo = "---- Updated inventory ----"; 
  
                              writer.write(intwo);
                              writer.newLine();
  
                              /*int left = 
                              String nI = H+delimeter+*/
  
  
                              st = H+hm+ delimeter+ totph;
  
                              writer2.write(st,0,st.length());
                              writer2.newLine();
                              System.out.println("You purchased "+hm+" "+H+"s with the total price of "+totph+".");
  
                          }
                          else if (ord==2){
  
                              System.out.println("How many?");
                              int hm = input.nextInt();
                              int totph = hm*25;
  
                              /*String intwo = "---- Updated inventory ----"; 
  
                              writer.write(intwo);
                              writer.newLine();
  
                              /*int left = 
                              String nI = H+delimeter+*/
  
  
                              st = F + hm + delimeter + totph;
  
                              writer2.write(st, 0, st.length());
                              writer2.newLine();
                              System.out.println("You purchased "+hm+" "+F+" with the total price of "+totph+".");
  
                          }
                          else if (ord==3){
  
                                  System.out.println("How many?");
                                  int hm = input.nextInt();
                                  int totph = hm*25;
  
                                  /*String intwo = "---- Updated inventory ----"; 
  
                                  writer.write(intwo);
                                  writer.newLine();
  
                                  /*int left = 
                                  String nI = H+delimeter+*/
  
  
                                  st = S+hm+ delimeter+ totph;
  
                                  writer2.write(st,0,st.length());
                                  writer2.newLine();
                                  System.out.println("You purchased "+hm+" "+S+"s with the total price of "+totph+".");
  
                              }
                          else{
                              System.out.println("Invalid input!");
                              menu=2;
                          }
  
                              System.out.print("Enter 1 to go back to the food menu, 2 to view sales, 3 to go back to the main option or 4 to quit: ");
                              menu2 = input.nextInt();        
                              if (menu2==1){
                                   menu=2;
                              }
                              else if (menu2==2){
                                   menu=4;
                              }else if (menu2==4){
                                   menu2=QUIT;
                              }
                              else if (menu2==3){
                                   menu=6;
                              }
                              else{
                                  System.out.println("Invalid Input!");
                              }
                  }
              if(menu==3){
                  {   
                      menu2 = QUIT;
                      writer.close(); 
                      Process p=rt.exec("notepad "+File);
                      System.out.println("Do you want to continue? y for yes, n for no");
                      String con = input.next();
  
                      if (con.equalsIgnoreCase("y")){
                          main(null);
                      }
                      else if(con.equalsIgnoreCase("n")){
                          menu2=QUIT;
                      }
  
                      }
              }
                  if (menu==4){
                  {   
                      menu2 = QUIT;
                      writer.close();
                      Process p=rt.exec("notepad "+File2);
                      System.out.println("Do you want to continue? y for yes, n for no");
                      String con = input.next();
  
                      if (con.equalsIgnoreCase("y")){
                          main(null);
                      }
                      else if(con.equalsIgnoreCase("n")){
                          menu2=QUIT;
                      }
  
                      }
                  }
                  if (menu==5){
                      System.exit(0);
                  }
                  else if (menu ==6){
                          main(null);
  
                  }
                  else{
                      System.out.println("Invalid Input!");
                  }
                  }
              }catch (Exception e){
                          System.out.println("Message: " +e);
          }
      }
  
      }
      }
      }
  </code></pre>