Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java print item to text file

import java.io.PrintWriter; // Step 1
import java.io.IOException;

public class FileWriteDemo
{
    public static void main(String[] args) throws IOException
    {
        // Open the file.
        PrintWriter out = new PrintWriter("oceans.txt"); // Step 2

        // Write the name of four oceans to the file
        out.println("Atlantic");   // Step 3
        out.println("Pacific");
        out.println("Indian");
        out.println("Arctic");

        // Close the file.
        out.close();  // Step 4
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: how to check palindrome in java 
Java :: load contents of file into string java 
Java :: java exception list 
Java :: How to efficiently find the area of largest rectangle that can be formed by adjacent buildings with known heights, in Java? 
Java :: tomcat 9 default username and password 
Java :: enum java 
Java :: java print stack 
Java :: how to reverse a number in java 
Java :: how to substring in java 
Java :: javafx rectangle border size 
Java :: print string in java 
Java :: maven artifact 
Java :: synchronized block java 
Java :: add Duration to date in Kotlin 
Java :: cors spring 
Java :: Java alt f4 
Java :: java split int 
Java :: uses or overrides a deprecated API. 
Java :: fixed length array powershell PSv5+ 
Java :: how to convert a string to char in java 
Java :: java string.format system.currenttimemillis 
Java :: delet file from path android 
Java :: important features of java programming language 
Java :: java initialize object array 
Java :: Divide two integers without using multiplication, division and mod operator 
Java :: java all characters in alphabet order simpler 
Java :: java ceil 
Java :: spring valid request body custom message 
Java :: lowercase string java 
Java :: Java Converting double into an int 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =