Write long to a file using DataOutputStream - Java File Path IO

Java examples for File Path IO:DataOutputStream

Description

Write long to a file using DataOutputStream

Demo Code

 
import java.io.DataOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
 
public class Main {
 
  public static void main(String[] args) {
   //from  w  ww . jav a  2s.  c o m
    String strFilePath = "C://Folder//WriteLong.txt";
   
    try
    {
      FileOutputStream fos = new FileOutputStream(strFilePath);
      DataOutputStream dos = new DataOutputStream(fos);
      long l = 65;
      dos.writeLong(l);
      dos.close();
    }
    catch (IOException e)
    {
      System.out.println("IOException : " + e);
    }
 
  }
}

Result


Related Tutorials