I can't write two times over the same file (java) -


I am writing in a text file, the first time a file output stream, and the second time through a file.

The file-optical stream text file looks just fine. However, FileWriter does not, after executing FileWriter, the contents of the file disappear, though it should be written to the file writer. Below is my code:

  try {serverSocket = new ServerSocket (850); If (ServerSocket.isBound ()) System.out.println ("Saver socket not back ..."); Else System.out.println ("Server is surrounded by socket port:" + serverSocket.getLocalPort ()); ClientSocket = serverSocket.accept (); If (! ClientSocket.isConnected ()) System.out.println ("client socket is not connected ..."); Else System.out.println ("Client Socket Connected:" + clientSocket.getInetAddress ()); InputStream = clientSocket.getInputStream (); Int byteRead = 0; Byte [] bytere = new byte [1024]; // Type action in a file action file = new file ("C: \\ user \\ false \\ document \\ MATLAB \\ FYP.txt"); FileOutputStream fos = new FileOutputStream (actionfile); BufferedOutputStream Boss = New BufferedOutputStream (fos); While ((Bitrate = In. Raid (Biteyre, 0, Byterere Lamble)) gt; {) Boss. Written (byte, 0, byte read); } ServerSocket.close (); ClientSocket.close (); in.close (); Bos.close (); Fos.close (); Scanner scan = new scanner (actionfile); ActionChar = scan.next (). Chart (0); If (task charge == '1' || action == '2') {FileWriter fw = new FileWriter (actionFile); Buffedriver bi2 = new buffed waister (FW); PrintWriter pw2 = new print-वाटर (बीडब्ल्यू 2); pw2.write ('r'); } System.out.println ("action here:" + verb); } Hold (IOException e) {e.printStackTrace (); }  

You have a scanner and

Read and close, then create the author.

And to close the call, make sure that for the same path name at the same time, open FileWriter . () After writing! It is unavailable.

Comments

Popular posts from this blog

python - Writing Greek in matplotlib labels, titles -

c# - LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method -

c# - Call function from DLL -