엥그니어링/도움글

Java: String to File write

Chaz 2015. 1. 6. 10:10
스트링이나 뭐 이런저런거 콘솔로 찍어보는 것보다 파일로 출력해야 할 때.

여기서 가져왔다.


BufferedWriter writer = null;
try
{
    writer = new BufferedWriter( new FileWriter( yourfilename));
    writer.write( yourstring);

}
catch ( IOException e)
{
}
finally
{
    try
    {
        if ( writer != null)
        writer.close( );
    }
    catch ( IOException e)
    {
    }
}