import java.io.*;
class FileWriterDemo
{
public static void main(String ar[]) throws Exception
{
FileWriter fw;
String s ="abcdefghi";
int a = s.length();
char c[]= new char[a];
s.getChars(0,a,c,0);
fw = new FileWriter("in.txt");
for(int i=0;i<a;i++)>
{
fw.write(c[i]);
}
}
}
The above given code is working fine.I have compiled it and no runtime exception was thrown.