Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to implement the following code?

Posted on 2002-06-03
5
Medium Priority
?
214 Views
Last Modified: 2010-03-31
I am new to JAVA And I need help with this piece of code..

I have a class-
CuLinePrinter

It has this method-
public void printText(java.lang.String s_text,
                      java.lang.String s_printer,
                      int i_num_copies)
               throws CuLinePrinterException

How do I use it inside a
Take.java class .. I want to implement it inside

the method called
public void sendEmail (sting mailto) throws EmailException{

  // how to create a new object for CuLinePrinter
  // how to initilize it and then use it..

..


}

Thanks



0
Comment
Question by:sdesar
[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
  • 4
5 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 7052165
we'd have to see the constructor for CuLinePrinter class, but it probably has a zero argument constructor so:

public void sendEmail (sting mailto) throws EmailException{

 // how to create a new object for CuLinePrinter
 CuLinePrinter clp = new CuLinePrinter();
 clp.printText(...)

}

0
 
LVL 18

Expert Comment

by:bobbit31
ID: 7052166
i could post a better solution if you can post the code for CuLinePrinter class.
0
 

Author Comment

by:sdesar
ID: 7071143
I have another java related ques.. could u help me please?
here's the ques.

I have a String defined as -

String s_file = getfile();

I need to get the length of this s_file and if its
greater than 80 characters and split it into 2 strings and print it.

I used
int i_len = s_file.length();
and
if ( s_file != "" && i_len > 80)
{
   s_file = sfile,substring(0,80);
   String s_file2 = s_file.substring(80, i_len);

}

When I run it I get a StringIndexOut oF bounds Exception..

Any suggestions?
0
 
LVL 18

Accepted Solution

by:
bobbit31 earned 200 total points
ID: 7071322
s_file = sfile,substring(0,80);
String s_file2 = s_file.substring(80);

or

s_file = sfile,substring(0,80);
String s_file2 = s_file.substring(80, i_len - 80);

0
 
LVL 18

Expert Comment

by:bobbit31
ID: 7071323
if that works for you, please don't forget to close out this question and accept an answer.

Thanks!
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

636 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