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!");
}
DiskEdit
csharp
System.IO.File.WriteAllText("filename.txt", "Some text to write to the file");

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