Solved

Here Document in Java

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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 …

749 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