Solved

Codes of Java access binary file

Posted on 1998-07-08
1
148 Views
Last Modified: 2012-05-04
I want use Java to display different font like chinese ttf file.
Can we retrieve font pixel map from the binary file of TTF?
How can we get the binary like C language fgetc or fread?
If you answer me,I will be happy and thank you.
0
Comment
Question by:mathematics
1 Comment
 
LVL 5

Accepted Solution

by:
msmolyak earned 20 total points
ID: 1225605
Reading files is easy. You can use either RandomAccessFile or DataInputStream on top of FileInputStream. E.g.

public static final int BUFFER_SIZE = 4096;

File tiffFile = new File("image.tif");
DataInputStream tiffStream = new DataInputStream(new FileInputStream(tiffFile));

byte[] buffer = new byte[BUFFER_SIZE];

int bytesRead;
while ((bytesRead = tiffStream.read(buffer)) >= 0)
{
  // Process data buffer
}
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to see all occupied ports on windows 10 laptop 15 76
jsp login check 12 42
Chrome and Firefox Java 5 51
Java: anonymous class 4 29
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question