Make a backup file: Difference between revisions

→‎{{header|Java}}: Added main() methods to both versions plus sample data file to backup.
(→‎{{header|Java}}: Added main() methods to both versions plus sample data file to backup.)
Line 206:
 
=={{header|Java}}==
{{incomplete|Java|Cannot run.}}
{{works with|Java|7+}}
<lang java5>import java.io.File;
Line 234 ⟶ 233:
}
}
 
public static void main(String[] args) {
try {
saveWithBackup("original.txt", "fourth", "fifth", "sixth");
} catch (IOException e) {
System.err.println(e);
}
}
}</lang>
 
Contents of 'original.txt' ''before'' the program is run and of 'original.txt.backup' ''after'' it is run:
<pre>
first
second
third
</pre>
 
Contents of 'original.txt' ''after'' the program is run:
<pre>
fourth
fifth
sixth
</pre>
 
{{works with|Java|1.5+}}
{{incomplete|Java|Cannot run.}}
<lang java5>import java.io.File;
import java.io.IOException;
Line 259 ⟶ 279:
output.close();
}
 
public static void main(String[] args) {
try {
saveWithBackup("original.txt", "fourth", "fifth", "sixth");
} catch (IOException e) {
System.err.println(e);
}
}
}</lang>
 
{{out}}
Same as version 7+ example.
 
=={{header|Julia}}==
9,492

edits