braju.com Java fprintf, printf, sprintf (fscanf, scanf, sscanf)

 

Home

Download
Purchase
History
Examples
Documentation
API/javadoc
FAQ
Feedback
About

Donate

Java scanf

Frequently Asked Questions

  1. General questions
    1. Is there a scanf too?
  2. License, redistribution and commercial usage
    1. Redistribution as part of an internal package
    2. What do you mean my commercial use?
  3. Non-printf/scanf related questions
    1. Can printf generate colors?
    2. Can printf print to a specific position (x,y) on the screen?

I. General questions

I.1. Is there a scanf too?

Java printf is great. Do you have a scanf method too?

Indeed I do. There is a beta version of a Java printf & scanf package available for free. Although it is a beta version all tests shows that it provides fully functional printf and scanf methods.

II. License, redistribution and commercial usage

II.1 Redistribution as part of an internal package

As the license says, it is possible to redistribute the Java printf package as an internal packages part of a non-commercial distribution. Please include the license.txt if you redistribute the Java printf package as an internal package. If you find it more convenient, you are allowed to rewrap the Java printf classes in the jar file into your jar distribution, but please do not forget the license.

II.2 What do you mean my commercial use?

The Java printf package can be used free of charge for private, research and/or educational purposes. If the Java printf package is used in an obvious business environment or in situtation where it help or simplifies work that generates money (directly or indirectly) it is considered commercial usage and a commercial license is required.

III. Non-printf/scanf related questions

III.1. Can printf generate colors?

I want to use fprintf in java to print a textfile in color. However, there is no color attribute in the constructor of any fprintf in the package. Can printf generate colors?

Not directly! You should not think about the printf methods as display formatters, but as formatters for sequences of characters (strings). There is also another reason for not providing display formatting, namely that there are several different terminal that each has its own way of setting display attributes such as colors and font styles. However, you can easily send control sequences to the terminal. For control sequences for the commonly used VT100 terminal, see ANSI/VT100 Terminal Control (Robert M. Free). See VT100PrintStream.java for an example which makes use of VT100 escape sequences. The output from this program can be seen in VT100PrintStream.txt.

III.2. Can printf generate colors?

Can printf print to a specific position (x,y) on the screen?

Not directly! However, different terminals interpret certain sequences of characters as control codes for setting colors and positioning the cursor. For more information see the closely related question II.1 above.