import java.io.*;
class CreatingFileAsLine
{
public static void main(String args[]) throws IOException
{
int i;
FileOutputStream fout;
String s;
char c[];
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter line, 'stop' to quit.");
try {
// open output file
fout = new FileOutputStream("D:\\Book\\a.txt");
}
catch(FileNotFoundException e)
{
System.out.println("Error Opening Output File");
return;
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println("Usage: CopyFile From To");
return;
}
try {
do {
s = (String) br.readLine();
c=new char[s.length()];
s.getChars(0,s.length(),c,0);
for(i=0;i<s.length();i++)
fout.write(c[i]);
} while(!s.equals("stop"));
} catch(IOException e) {
System.out.println("File Error");
}
fout.close();
}
}