Alernative to printf("%*s",indent,message) in java?

In C we can specify the amount to space to leave in printf , any similar way to do this in java?

For example

int space=6; char message[10]="hi"; printf("%*s",space,message);

will print

hi

-------------Problems Reply------------

Create the format string dynamically:

int space = 6;
System.out.printf("%" + space + "s", "hi");

Category:java Views:1 Time:2019-02-08

Related post

  • How can I print .exe printf() messages from java program 2012-03-14

    I have one application that prints messages from Test.exe in console .My java program creates one process by executing this Test.exe. This application prints messages by reading from input-stream of that process. The problem, that I am facing is, I h

  • How do I send an SMTP Message from Java? 2008-09-16

    Possible Duplicate: How do you send email from a Java app using Gmail? How do I send an SMTP Message from Java? --------------Solutions------------- Here's an example for Gmail smtp: http://tovare.com/articles/learnhowtosendemailviagmailfromjavain120

  • how to convert String to message in java mail api? 2010-06-01

    how to convert String to message in java mail api? --------------Solutions------------- You can use the MimeMessage constructor which accepts an InputStream. (See the JavaMail documentation) Message msg = new MimeMessage(mySession, new ByteArrayInput

  • Fading Indicator message in Java 2010-06-14

    How to/What is a good library, to create a fading indicator message in Java like that of Outlook when you get a message, or Ubuntu/Gnome when you've connected to a network? --------------Solutions------------- Java 1.6 has a TrayIcon class that can b

  • Hide warning messages in java 2010-09-12

    It is possible to hide the warning messages in java? --------------Solutions------------- If you're referring to the warnings printed by the compiler, you could have a look at the SuppressWarnings annotation.

  • Applet using JNLP: messages in Java console 2011-02-18

    I am displaying applet using JNLP. I have written all the necessary files. The jars are signed. Even applet is loading fine. I am getting lots of messages in Java console which are contributing to delay in applet loading. basic: JNLP2ClassLoader.find

  • Exceptions when reading protobuf messages in Java 2011-07-02

    I am using protobuf now for some weeks, but I still keep getting exceptions when parsing protobuf messages in Java. I use C++ to create my protobuf messages and send them with boost sockets to a server socket where the Java client ist listening. The

  • Instant messaging in Java via Windows user ID? 2011-08-09

    I have already created simple instant messaging application in Java using Sockets and Swing. Right now it's communicating by resolving the hostname (PC name) or IP that's passes as a parameter. But is there a way to make it send a message with the Wi

  • Translate exception messages in Java 2012-02-14

    I tried a program that can translate exception messages into another language. Most exceptions or fault messages from Java are displayed in English, but I want to change at least for the exception class that they are translated into the Indonesian la

  • i recently upgraded my wndows7 to windows8 pro when i go to confirm for payment through i-banking a message appears java script is diabled in browser i can not understand the problem 2013-03-29

    i recently upgraded my wndows7 to windows8 pro when i go to confirm for payment through i-banking a message appears java script is disabled in browser when I go to internet option -security-then internet setting scripting is enable. java 32 bit is al

  • Is there a good reason to use "printf" instead of "print" in java? 2009-02-14

    I haven't had the chance to take any serious low-level programming courses in school. (I know I really should get going on learning the "behind-the-scenes" to be a better programmer.) I appreciate the conveniences of Java, including the ability to st

  • How to return a flag plus an optional message in Java? 2010-08-23

    I want to write a method in Java that verifies that some conditions hold on some data, and acknowledges that the data is valid or produces an appropriate error message otherwise. The problem is that we cannot return more than one thing from a method,

  • Rails flash messages in Java 2009-04-07

    What's the best way to achieve Rails-like flash messages such as "Update successful" http://api.rubyonrails.org/classes/ActionController/Flash.html) in the Java world? I'm using Spring MVC. --------------Solutions------------- I would recommend imple

  • How to show a client-side message with Java JSF/Tobago? 2010-01-29

    I have a web application created with JSF and Tobago. The user types some date into a sheet and clicks a button (all within one sheet-row). Now my java class checks whether the data is correct or not. In case there are some problems, I would like to

  • Looking for a library to process CDA (AKA HL7v3, AKA CCD) messages in Java 2010-02-10

    I am working on processing CDA messages for a Java application. CDA is yet another XML standard for sending medical information, it is closely related to CCD and HL7v3. I have already reviewed the following libraries and found them lacking, promising

  • WCF client encrypt message to JAVA WS using username_token with message protection client policy 2010-06-07

    I am trying to create a WCF client APP that is consuming a JAVA WS that uses username_token with message protection client policy. There is a private key that is installed on the server and a public certificate file was exported from the JKS keystore

  • How to send Cell Broadcast message in Java ME development environment? 2010-07-05

    I have been trying to develop a Java ME application using WTK 2.5.2 (Java Wireless Toolkit) and Nokia SDK 3. The application would broadcast a CBS (Cell Broadcast Service) message using the WMA (Wireless Messaging API). Documentations says that the C

  • How is messaging between Java classes best accomplished? 2010-09-21

    I have multiple classes and threads that need to write to a Java Swing JScrollPane. In the Android/Eclipse environment I used android.os.Message. Is there something similar in the NetBeans/Windows environment? Here is where I would like to send the m

  • I18n of XSD validation error messages in Java 2010-10-08

    I perform XSD XML validation using the following classes: import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; import javax.xml.validation.Validator; The problem is that XSD error messages returned by validator are always in

  • Encryption message in java 2010-11-15

    i am a project about using java's bouncycastle to do the encryption. However, when I encrypt the message, it throws an exception for me. javax.crypto.IllegalBlockSizeException: data not block size aligned I am using Blowfish/ECB/NoPadding, and the me

  • Cant send ssl messages with java ssl socket 2010-12-16

    I am trying to create a server - client bundle that will let me send simple messages with ssl support. I am quite new at java and i can't figure out what my problem is. I am running the server and client programs at 2 computers at the same network an

  • Ant javac returning message "A.java added as A.class doesn't exist" 2010-12-23

    I'm writing an ANT task that is behaving very oddly. I've tried a variety of google searches with no clear answer. I have a compile target in ANT that calls the javac command: <target name="compile"> <mkdir dir="${classes.dir}" /> <jav

  • Reading HTTP Messages in Java 2011-02-05

    First of all, I'll admit this is a school project, so I need more of just direction, rather than actual code. Also, I cannot use the java.net.HTTPURLConnection and java.net.URL classes to help out... Ok... I'm creating a HTTP server in Java, but havi

  • send message from java program to activemq using mule 2011-03-28

    Iam trying to send a string message from a java program to queue in ActiveMQ using MULE.Iam new to mule this is my mule-config.xml <?xml version="1.0" encoding="UTF-8"?> <mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http:

  • Customized error message on java version mismatch while launching webstart 2011-04-06

    On launching a jnlp, with <jnlp spec="1.5+"> and <j2se version="1.5+" href="..."/> using javaws from 1.4 we will be getting error like jnlp specification 1.5 is not supported and only 1.0 is supported. However error shown in this case, is

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.138 (s). 11 q(s)