Solved

Here Document in Java

Posted on 2009-07-05
2
1,407 Views
Last Modified: 2012-05-07
Experts,

Regarding the "here document,"  I was wondering if there was an equivalent way to do this in a high-level language like Java? I haven't been successful finding anything as of yet. I have included an example of a Perl script here document below:

print <<EOHeader;

You will be prompted for your name and other information. Please give complete answers to each question. To return to the menu without making an entry type q [Enter].

EOHeader

This output everything between the EOHeader tags without having to use four or five print commands.

Thank you.
0
Comment
Question by:shogun5
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 16

Accepted Solution

by:
Peter Kwan earned 500 total points
ID: 24783218
Java does not support such syntax. However, you may use StringBuffer as an alternative way like this:


StringBuffer sb = new StringBuffer();
sb.append("\n").append("You will be prompted for your name and other information. Please give complete answers to each question. To return to the menu without making an entry type q [Enter].").append("\n");
System.out.println(sb.toString());

Open in new window

0
 

Author Closing Comment

by:shogun5
ID: 31599972
Thank you!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

724 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