TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Java Tutorials

Java FileOutputStream Class

Overview

The main purpose of the Java FileOutputStream class is to write data to a  file in the file system. The FileOutputStream is a subclass of OutputStream. OutputStream is an abstract superclass.

 

FileOutputStream Class

 

Constructors

The most used constructors of the class are as follows:

public FileOutputStream(String name) throws FileNotFoundException

public FileOutputStream(File file) throws FileNotFoundException

public FileOutputStream(String name, boolean append) throws FileNotFoundException

public FileOutputStream(File file, boolean append)
throws FileNotFoundException

The boolean value is for appending the new data to the existing file data. The old data in the file will not be deleted if the append boolean value is true.

Methods

The most important methods of the class are:

write() – This method is used to write the byte to the file output stream.

write( byte[] ) – This method is used to write the bytes from the specified byte array to the file output stream.

Example

The below example is to create an object for the class.

FileOutputStream fos = new FileOutputStream(“output.txt”);


—

Java Tutorials

Java Tutorial on this website:

https://www.testingdocs.com/java-tutorial/

For more information on Java, visit the official website :

https://www.oracle.com/java/

Related Posts

Download Greenfoot Windows

Java Tutorials /

Download & Install Greenfoot on Windows

Java Tutorials /

Java Static Code Analysis

Java Tutorials /

Java Testing Tools

Java Tutorials /

Handle Multiple Exceptions in Java

Exceptions_In_Java

Java Tutorials /

Exceptions in Java Programs

‹ Java Constructors› Java Web Application

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version