Java FileWriter write to a file
#Java #FileWriter #write #file
import java.io.FileWriter;
import java.io.IOException;
public class Main {
public static void main(String[] args) {
try {
FileWriter writer = new FileWriter("poem.txt");
writer.write("Roses are red \nViolets are blue \nBooty booty booty booty \nRockin' everywhere!");
writer.append("\n(A poem by Bro)");
writer.close();
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
#Java #FileWriter #write #file
import java.io.FileWriter;
import java.io.IOException;
public class Main {
public static void main(String[] args) {
try {
FileWriter writer = new FileWriter("poem.txt");
writer.write("Roses are red \nViolets are blue \nBooty booty booty booty \nRockin' everywhere!");
writer.append("\n(A poem by Bro)");
writer.close();
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
- Category
- Bro Code
- Tags
- Java FileWriter, Java write to a file, Java (Programming Language)

Be the first to comment