Solved

Here Document in Java

Posted on 2009-07-05
2
1,373 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
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
static class 3 68
post4 challenge 28 99
Need To Find FireFox Binary Path For Python Selenium On Windows 7 15 566
What language/protocol is the Angular Chat? 2 73
There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

813 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now