0

here i find other way ..
when comile clicked .the gettext() will send to .txt file ..
this code have errors .. i want user to enter data and save in text file ..

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package files;
 import java.io.*;
 import java.util.Scanner;
  class Files

  {
  public static void main(String[] args) throws IOException
  {
  BufferedReader stdin =
 new BufferedReader(new InputStreamReader(System.in));
  String s = "junk.txt";
  File f = new File(s);
  if (f.exists())
{
    System.out.print("Overwrite " + s + " (y/n)? ");
}
  if(!stdin.readLine().toLowerCase().equals("y"))
  return;
  }
  PrintWriter outFile =new PrintWriter(new BufferedWriter(new FileWriter(s)));
   System.out.println("Enter some text on the keyboard...");
  System.out.println("(^z to terminate)");
   String s2;
  while ((s2 = stdin.readLine()) != null)
  outFile.println(s2);
  outFile.close();
 }
0

You can have many different unrelated problems in one project. Its best to treat each one separately rather than mixing it in with all the rest of the code in the project which can make confusion.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.