?
Solved

How to implement the following code?

Posted on 2002-06-03
5
Medium Priority
?
215 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
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses
Course of the Month14 days, 11 hours left to enroll

839 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