Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-22-2008, 10:25 AM
jazz2k8's Avatar
Member
 
Join Date: Apr 2008
Posts: 99
jazz2k8 is on a distinguished road
How to Merge all classes into One class
I am having total 3 classes and i want to merge all into one class.
EG:A,B,C are different type of documents
class A
Class B
Class C

Now i want all of them into one single class
I have taken
Class D{
public void A()
{System.out.println("A");
}
public void B()
{System.out.println("B");
}
public void C()
{System.out.println("C");
}
}
class MainClass()
{public static void main(string args[]){
MainClass m=new MainClass();

string doctype="A,B,C";
System.out.println("Eneryour Doctype:" +doctype);

if (doctype="A"){
m.A();
}
if (doctype="B"){
m.B();}
if (doctype="C"){
m.C();
}
}

Am i correct???if not i need your suggestions ...
thanks in advance...

-jazz
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-22-2008, 10:38 AM
sanjeevtarar's Avatar
Senior Member
 
Join Date: Apr 2008
Location: Delhi(India)
Posts: 249
sanjeevtarar is on a distinguished road
Quote:
Originally Posted by jazz2k8 View Post
I am having total 3 classes and i want to merge all into one class.
EG:A,B,C are different type of documents
class A
Class B
Class C

-jazz
Hi,

What exactly you want..??

If you want to merge classes you can do it with using inner classes.
But according to your description it seems that you want to merge all methods of three classes into single class..

please explain some more details.


sanjeev
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-22-2008, 11:17 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,875
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Seems he wants to merge all methods in to a single class.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on September 4, 2008)

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 04-22-2008, 11:40 AM
jazz2k8's Avatar
Member
 
Join Date: Apr 2008
Posts: 99
jazz2k8 is on a distinguished road
Here what i want exactly...
I am having 3 different types of documents on which i written code for extracting the information from that all are different classes.Now i want t group them into one single class.I thought that by taking each class as a method it would be best...does it works???

Last edited by jazz2k8 : 04-22-2008 at 11:48 AM.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 04-22-2008, 12:01 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,875
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Simply you want to read three different files, isn't it?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on September 4, 2008)

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 04-22-2008, 12:14 PM
jazz2k8's Avatar
Member
 
Join Date: Apr 2008
Posts: 99
jazz2k8 is on a distinguished road
Yeah i want to read three and if the input argument matches to"A" Document it should invoke class A(methods)

Take for example
A=invoice
B=purchase
C=Creditors Journal

i have written separate code(classes) for invoice,purchase and Creditors journal
Now i want to merge all those into single.If the input argument is purchase it should invoke purchase class.

Now i want to merge all these 3 into single..For this requirement what is your suggestion???How to proceed for this.

i cant be more clear thatn this....
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 04-22-2008, 12:15 PM
sanjeevtarar's Avatar
Senior Member
 
Join Date: Apr 2008
Location: Delhi(India)
Posts: 249
sanjeevtarar is on a distinguished road
Ok, you need a program that extract data from three different document and you have written code in different three classes and now you want Single class for this.

Ok just design a class and put three method...instead one can have single method also. and then call method accordingly.

Or Post what have you done so far, so that one can give you proper solution for the same.


sanjeev
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 04-22-2008, 12:18 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,875
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Yes, what you have to do is create all three different classes in a single class as methods. Since you have coded all three classes this is not much difficult at all.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on September 4, 2008)

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 04-22-2008, 01:51 PM
jazz2k8's Avatar
Member
 
Join Date: Apr 2008
Posts: 99
jazz2k8 is on a distinguished road
Here i am attaching my cde and the text please have a look into this issue.
One more thing in the above two funtions the code is same as follows
----------------------------------------------------
BufferedReader in=new BufferedReader(new FileReader ("D:\\jazz\\CSV\\abcd.txt"));
StringBuffer sb=new StringBuffer();
String line;
line=in.readLine();

while(line!=null){
sb=sb.append(line);
line=in.readLine();
}

String line1=sb.toString();
System.out.println(line1);
}
----------------------------------------------
Can i declare it as global??

if i ran the attached code iam getting errors.
Attached Files
File Type: zip java.zip (1.4 KB, 3 views)
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 04-22-2008, 01:51 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,875
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Few error there. Defining variables as local or global is depend on the way you implementing the application.

Look at this code.

Code:
import java.io.*; /** * * @author Eranga */ public class ReadFile { FileInputStream fiStream; DataInputStream diStream; BufferedReader br; public static void main(String[] args) { // TODO code application logic here new ReadFile().readFile(); } public void readFile() { try { fiStream = new FileInputStream("D:\\jazz\\CSV\\abcd.txt"); diStream = new DataInputStream(fiStream); br = new BufferedReader(new InputStreamReader(diStream)); String ss; while((ss = br.readLine()) != null){ System.out.println(ss); } } catch (IOException ex) { System.out.println(ex.getLocalizedMessage()); } } }
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on September 4, 2008)

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 04-22-2008, 01:53 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,875
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Go through that given code and try to identify where you go wrong. The way you workout is no connection with the file and your application.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on September 4, 2008)

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #12 (permalink)  
Old 04-22-2008, 02:30 PM
jazz2k8's Avatar
Member
 
Join Date: Apr 2008
Posts: 99
jazz2k8 is on a distinguished road
did you have checked my code which is attached???
Bookmark Post in Technorati
Reply With Quote
  #13 (permalink)  
Old 04-23-2008, 04:40 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,875
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Yes I do, but I can't test it. Where is the FinalCode class. I can't find it in the attached file.

I don't know what you are trying to do in that. I give the solution for the code you have tried on the post number 9 code. Just read the file line by line. Is that not what you need?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on September 4, 2008)

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Using classes and overriding one class for another StealthRT New To Java 3 04-08-2008 08:12 AM
Merge Two Xml files ???? alwz_nikhil XML 3 03-28-2008 12:40 PM
How do merge two xml files into one xml? veera XML 1 03-27-2008 06:06 PM
Merge 2 button become one banie AWT / Swing 1 02-17-2008 06:26 PM
Merge Sort Help Hollywood New To Java 5 01-30-2008 04:26 AM


All times are GMT +3. The time now is 06:35 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org