This discussion is archived
1 2 Previous Next 27 Replies Latest reply: Jun 25, 2011 5:55 AM by EJP Go to original post RSS
  • 15. Re: Some functionalities in JAR do not work
    840135 Newbie
    Currently Being Moderated
    Why are you not making use of the read and write method of RTFEditorKit? These would get rid of most of your code and probably solve the encoding problem.
    I once tried to use that in another code and had trouble with it. Since then, I ignored it. Do you think that is better and could solve the encoding problem? If so, I will.
  • 16. Re: Some functionalities in JAR do not work
    793415 Pro
    Currently Being Moderated
    lata wrote:
    ..What exactly should I do to handle the exception properly?
    It is not obvious what the <tt>info(String)</tt> method does, but something that is obvious is that most of the information is lost before it ever gets to that method.

    A very simple and informative (though not necessarily 'best') way to handle a <tt>Throwable</tt> is to call <tt>printStackTrace()</tt>.
  • 17. Re: Some functionalities in JAR do not work
    840135 Newbie
    Currently Being Moderated
    It is not obvious what the <tt>info(String)</tt> method does, but something that is obvious is that most of the information is lost before it ever gets to that method.
    The info(String) simply displays the string using JOptionPane.showMessageDialog(...)
    but I am not good at understanding the StackTrace thing.
  • 18. Re: Some functionalities in JAR do not work
    793415 Pro
    Currently Being Moderated
    lata wrote:
    ..The info(String) simply ..
    What's even simpler than piecing together a number of code snippets and textual descriptions, is an SSCCE.
  • 19. Re: Some functionalities in JAR do not work
    sabre150 Expert
    Currently Being Moderated
    lata wrote:
    Why are you not making use of the read and write method of RTFEditorKit? These would get rid of most of your code and probably solve the encoding problem.
    I once tried to use that in another code and had trouble with it. Since then, I ignored it. Do you think that is better and could solve the encoding problem? If so, I will.
    I would expect it to handle all encoding behind the scenes. I once used it many years ago without any problems though I was only using it with French and English.
  • 20. Re: Some functionalities in JAR do not work
    840135 Newbie
    Currently Being Moderated
    I would expect it to handle all encoding behind the scenes. I once used it many years ago without any problems though I was only using it with French and English.
    French uses Latin alphabet. There is no problem in that case may be. This one uses a different set of alphabet. You can the characters here
    http://en.wikipedia.org/wiki/Amharic_language
  • 21. Re: Some functionalities in JAR do not work
    840135 Newbie
    Currently Being Moderated
    What's even simpler than piecing together a number of code snippets and textual descriptions, is an SSCCE.
    I can't paste the whole code here. It is too much and unnecessary too. But I will post the ones related to somebody's question. I actually do not know what exactly the problem is and hence don't know what code to post.
  • 22. Re: Some functionalities in JAR do not work
    793415 Pro
    Currently Being Moderated
    lata wrote:
    What's even simpler than piecing together a number of code snippets and textual descriptions, is an SSCCE.
    I can't paste the whole code here.
    <tt>"SSCCE"!="whole code"</tt>

    Read the link.
    ..It is too much and unnecessary too. But I will post the ones related to somebody's question. I actually do not know what exactly the problem is and hence don't know what code to post.
    That is why it is a good idea to prepare an SSCCE. In doing so, you will either discover the problem or at least narrow it down.

    Read the link.
  • 23. Re: Some functionalities in JAR do not work
    840135 Newbie
    Currently Being Moderated
    I was putting some of your suggestions and seeing the effect last night. Actually, encoding is the main problem. I got the reading part working but the writing is still not working. Actually it works if I give filename directly in code but not if I use JFileChooser to give file path and name. It is a funny one.
    public void saveFileUnicode()
        {
            try
            {
                FileOutputStream fos = new FileOutputStream("test.txt");
                OutputStreamWriter out = new OutputStreamWriter(fos, "UTF8");
                String written = editor.doc.getText(0, editor.doc.getLength());
                out.write(written);
                out.close();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            catch (BadLocationException e)
            {
                e.printStackTrace();
            }
        }
    But this one does not:
    FileOutputStream fos = new FileOutputStream(fileName); //filename is string
    I could not figure out why.
  • 24. Re: Some functionalities in JAR do not work
    840135 Newbie
    Currently Being Moderated
    Actually it works if I give filename directly in code but not if I use JFileChooser to give file path and name.
    I overcame this by giving the filename in code and then move that file to the place returned from JFileChooser. It is done by using file.renameTo(path)
  • 25. Re: Some functionalities in JAR do not work
    EJP Guru
    Currently Being Moderated
    That's not a solution, that's just creating a different problem.

    Obviously it revolves around the file not being where you think it is. So correct your thinking, and reflect that in the code.
  • 26. Re: Some functionalities in JAR do not work
    840135 Newbie
    Currently Being Moderated
    EJP wrote:
    That's not a solution, that's just creating a different problem.
    I know that sometimes moving the file fails and sometimes overwriting may occur. Still, that is the only solution I found for the time being.
  • 27. Re: Some functionalities in JAR do not work
    EJP Guru
    Currently Being Moderated
    Even though sometimes it doesn't work?

    I repeat, that's not a solution, it's another problem.
1 2 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points