Home » Java programming language

Java DataOutputStream writeLong() Method with Example

DataOutputStream Class writeLong() method: Here, we are going to learn about the writeLong() method of DataOutputStream Class with its syntax and example.
Submitted by Preeti Jain, on March 30, 2020

DataOutputStream Class writeLong() method

  • writeLong() method is available in java.io package.
  • writeLong() method is used to write the given long value to the basic DataOutputStream as 8 bytes (i.e. 64 bit) and the variable counter is plus by 8 on successful execution.
  • writeLong() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.
  • writeLong() method may throw an exception at the time of writing long.
    IOException: This exception may throw while getting any input/output error.

Syntax:

    public final void writeLong(long val);

Parameter(s):

  • long val – represents the long value to be written to the data output stream.

Return value:

The return type of the method is void, it returns nothing.

Example:

// Java program to demonstrate the example 
// of void writeLong(long val) method 
// of DataOutputStream

public class GetSignersOfClass {
 public static void main(String[] args) throws Exception {
  // Creating an instance of String
  String str = new String();

  // It returns the Class object represented by the String class
  // object
  Class cl = str.getClass();

  // By using getSigners() method is to get the signers of the Class
  Object[] o = cl.getSigners();
  System.out.println(cl.getName() + " " + "Signers :" + o);
 }
}

Output

java.lang.String Signers :null





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.