Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners How to write in Binary file in Java programming language
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Java Coder
How to write in Binary file in Java programming language
1 Answer(s)      a year and 6 months ago
Posted in : Java Beginners


I need some help about Java programming. Please explain me "How to write in Binary file in Java programming language?"


Advertisement
View Answers

March 15, 2013 at 6:08 PM


Dear Friends,

Before writing file we need to know what is binary file in Java. The binary file contains bit patterns data type, which residnes in bit form. Before using the binary file we need to create some data arrays that should contain some value. For binary file FileOutputStream class is used for opened for the file and wrapped this stream object to BufferedOutputStream instance and then finally wrapped this stream object into the instance of DataOutputStream class.

For more details visit : [http://www.roseindia.net/java/examples/io/writeToFileBinary.shtml][1]

or

Find the Example or Syntax

import java.io.*;

class WriteToFileBinary
 {
  public static void main(String args[])
   {
    WriteToFileBinary wtfb = new WriteToFileBinary();
    wtfb.writeToFileBinary();
   }
   public void writeToFileBinary()
    {
     String [] str ={ "A", "B", "C", "D"};
     int[] in = { 12, 8, 13, 29, 50 };
     double[] dob = { 19.99, 9.99, 15.99, 3.99, 4.99 };
     FileOutputStream fos = null;
     BufferedOutputStream bos = null;
     DataOutputStream dos = null;
     try
      {
       fos = new FileOutputStream("writeToFileBinary");
       bos = new BufferedOutputStream(fos);
       dos = new DataOutputStream(bos);
       for (int i = 0; i < str.length; i ++)
        {
         dos.writeDouble(dob[i]);
         dos.writeInt(in[i]);
         dos.writeUTF(str[i]);
        }
        dos.close();
      }
      catch(Exception e)
       {
        System.out.println(e);
       }          
     }
  }




[1]: http://www.roseindia.net/java/examples/io/writeToFileBinary.shtml


Related Tutorials/Questions & Answers:
How to write in Binary file in Java programming language
How to write in Binary file in Java programming language  I need some help about Java programming. Please explain me "How to write in Binary file in Java programming language
Java Write To File Binary
Java Write To File Binary In this tutorial you will learn how to write... types can be formed to a byte of 8 bits. Write to a binary file in java... with containing the text that you are trying to write into the file by java program
Advertisements
How to write in File in Java
How to write in File in Java  Hi, How to write in File in Java. Please suggest and give example of this program. thanks
How to write in File in Java
How to write in File in Java  Hi, How to write in File in Java... bufferedWriter object to write in the file. For more details and examples related to How to write in File of Java Program
Java File Binary
Java File Binary In this section, you will learn how to write numeric data into the binary file. Description of code: Numeric data converts compactly... provides the way to write the data to the file
How to write file by line in Java
How to write file by line in Java  How to write file by line in Java   Hi, For Write to a file by line using java programming language we... in a new line. How to use Write To File By Line in Java programs
How to Write to file in Java?
How to Write to file in Java?  How to Write to file in Java Program... the Examples of How to write to File in Java Program: WriteToFileExample.java import... how to write in a file."); br.close(); } catch (Exception e) { System.err.println
How to write to xml file in Java?
How to write to xml file in Java?  Hi Friends, Can anyone help me how to write in xml file in Java programming. Please fill free to give example or reference website for getting example.   Hi, To write in xml file
Java write to file
Java write to file  How to write to a file in Java? Is there any... programming language for handling the files. It can handle both text as well as binary... Handling examples in Java Java Input/Output Examples How to read file in Java
Java read binary file
Java read binary file  I want Java read binary file example code... at Reading binary file into byte array in Java. Thanks   Hi, There is many more examples at Java File - Learn how to handle files in Java with Examples
How to write into CSV file in Java
How to write into CSV file in Java  How to write into CSV file in Java   Hi, To create Comma separated value(CSV) file is very simple... Object to PrintWriter instance. How to create File to CSV in Java
How to Write To File BufferedWriter in Java
How to Write To File BufferedWriter in Java  how to write to file bufferedwriter in Java   In Java there are 2 types of class files used... for your references. How to use Bufferedwriter class in Java programs
how to write append file in Java
how to write append file in Java  How to write append file in Java... existing file should be retained when you are trying to write new contents...("appenToFile.txt", true); For More Details visit this link: How to Append file
Java Programming Language
Java Programming Language  Hi, For beginner which programming concepts is important? Discuss the importance of Java programming language. In the discussion please let's know how to use Java in developing web applications
java binary file io example
java binary file io example  java binary file io example
how to write to file from string in Java
how to write to file from string in Java  Hi, Please any one help me for how to write to file from string in Java. I am beginner in Java programming. Thanks,   Hi, Are you eager to learn how to write to file from
how to write tis java programming - Java Beginners
how to write tis java programming   Airport Transport Service...; displays the details of facility how to write tis program in java.....pls reply.... Using Transport.class and Facility.class, write a program that displays
Java Programming Language
programming language code is written in text editor and saved into .java file...Introduction to Java programming Language Java is one of the Object-Oriented... A. Gosling developed the Java programming language in the year 1995 at Sun
How to Write to a File in Java
In this Java tutorial, we will demonstrate how to write to a file in Java... to a file from Java program. To write the Java Write To File we will use two... Java" into out.txt file. While creating the object of FileWriter class we
how to read and write an xml file using java
how to read and write an xml file using java  Hi Can anyone help me how to read and write an xml file which has CData using java
Learning programming language - Java Beginners
Learning programming language  Hi, I am srikanth i want to learn java programming language without knowing C language.I am very new to programming and i want to learn this language.Can you suggest me to learn the language
how to write to file at the end of the line
will help you for "How to write the file at the end of line using Java language...how to write to file at the end of the line  Hi, Where do i learn how to write to file at the end of the line using Java program. Plz suggest
How to write file from inputstream in java
How to write file from inputstream in java  Hi, how to write file from inputstream in java program. Plz suggest an example or suggested link... link to your query "How to Write to inputStream in Java". This is good
Where to learn java programming language
and want to learn Java and become master of the Java programming language? Where to learn java programming language? Thanks   Hi, Java is Object oriented programming language. It's easy to start learning Java. You can learn how
How to write a file in Java?
How to write a file in Java? To write a file in Java use the class FileWriter... and strings. Example of how to write text to a file in java: import java.io.... will make a text file by the name "out.txt" and will write "Hello Java
How to using Binary Search Array Java ?
How to using Binary Search Array Java ?  Hi, I am beginners in Java Programming Language. I am trying to create small application using Array functions. The problem is that how to use binary search array in Java. Please give
Java Programming Language
the languages of Java. Java is a portable programming language which was developed... Microsystems. The nucleus of the java platform is the Java programming language... description and brief about the Java programming languages and its usages
Why Java as a programming Language?
Why Java as a programming Language?       Why Java as a  programming Language? Java is a general... programming Language? Java is a statically typed object-oriented language that uses
How to Write to a File in Java without overwriting
Learn how to Write to a File in Java without overwriting in your Java program This tutorial teaches you how to write to a file in Java without overwriting... which already contains the data and our program will write to this file without
About Java Programming Language
About Java Programming Language       Java is an Object oriented application programming language... language. Java programming language is useful for development of enterprise grade
how to use Excel Templet to write excel file using java.
how to use Excel Templet to write excel file using java.  how to use Excel Templet to write excel file using java
 

 

 

DMCA.com