• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextPane/JEditorPane and Serialization

 
vishwas bhatt
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everybody ,
I am in process write own javaeditor.which can maintain Tabs and spaces in file.Now the problem is that if i use JTextPane/JEditor and just write my new file with Tabs and Sapces.Now when i save
this to file i have to use Serialization of
Documnet Object ( am i right ?), and that will be java's serialized file which can only be detected by (or decoded)my java program and again maintain white spaces and Tabs. I want to write a file in a way that it can be again read by any word processor like notepad/wordpad and maintain same tabs and spaces.
 
Jeff Smith
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe I don't understand exactly what you're trying to do here, but why don't you just use the getText() method of your JTextPane and write the returned String to a file. The String will contain all the tabs and spaces so it'll work okay in notepad/wordpad/etc... The only formatting issue that could arise is how the program you open the file in interprets tabs (i.e. four spaces, eight spaces, and so on...).
I would recommend against serializing the Document itself. That would make it readable only in your program, and it may not be compatible with future releases of swing.
Jeff
[ April 05, 2002: Message edited by: Jeff Smith ]
 
vishwas bhatt
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeff ! Tahnx for prompt Reply
I got the things. you suggest me that i should use getText() can you tell me that how much text i can get at a time. if my file size is big then it will create problem or not
Hoping for same response
 
Jeff Smith
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The getText() method will return all the text at once in a String, so a large file would only be a problem if it was so large that the String required more memory than the computer has. Because you're writing a java source editor I don't think you need to worry much - I've never come across a source file that would be large enough to cause problems.
Jeff
 
vishwas bhatt
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Jeff !

Thanx for ur nice support ...and probebly you are right that i can do most of my work with getText().
i had tried and succed

thanx once again
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!