View Problem

Write a string to a file

DiskEdit
perl
open(my $fh, '>', $path) or die "can't open $path: $!";
print $fh "This line overwites file contents!";
close $fh;
ExpandDiskEdit
java
FileWriter fw = null;

try
{
fw = new FileWriter("test.txt");
fw.write("This line overwites file contents!");
}
ExpandDiskEdit
java
PrintWriter pw = null;

try
{
pw = new PrintWriter(new BufferedWriter(new FileWriter("test.txt")));
pw.print("This line overwites file contents!");
}

Submit a new solution for perl or java
There are 16 other solutions in additional languages (clojure, cpp, csharp, erlang ...)