File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes OOP Passing parameter back Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "OOP Passing parameter back" Watch "OOP Passing parameter back" New topic

OOP Passing parameter back

Roberto Gonsales

Joined: Sep 26, 2011
Posts: 5
Hello everybody, I need some help. I'm writing program which takes bunch of text files with different charset encoding and converts these files to another one charset. My program is almost done, but one key thing. How do I pass 'charset' parameter of Notify method in CharsetDetector class back to Converter class?

Greg Charles

Joined: Oct 01, 2001
Posts: 2968

I'm not clear on when or why your notify() method is called, but I think the most logical way to get the results of detectCharset() into your converter would be to return it from detectCharset().

A couple of extra suggestions:

1. Wrap your reader and writer in BufferedReader and BufferedWriter and you'll see a dramatic increase in performance.
2. Learn the capitalization conventions for Java. Classes and Interfaces should start with a capital. Methods and variables start with lowercase. Following conventions like these make your code much more readable.
Roberto Gonsales

Joined: Sep 26, 2011
Posts: 5
Greg, thank you for reply. I changed code in accordance with your recommendations to use BufferedReader and BufferedWriter.
Interface nsICharsetDetectionObserver is part of jChardet library. nsDetector fires the Notify() method between nsDetector.DoIt() and nsDetector.DataEnd() calls. I changed CharsetDetector class to get result only in Notify() method. So how do I get the result back to Converter class?

I agree. Here's the link:
subject: OOP Passing parameter back
It's not a secret anymore!