Click here to Skip to main content
15,891,633 members
Home / Discussions / Java
   

Java

 
GeneralRe: structure equivalant in java Pin
Nagy Vilmos5-Oct-10 23:16
professionalNagy Vilmos5-Oct-10 23:16 
GeneralRe: structure equivalant in java Pin
trioum6-Oct-10 1:19
trioum6-Oct-10 1:19 
GeneralRe: structure equivalant in java Pin
TorstenH.6-Oct-10 1:59
TorstenH.6-Oct-10 1:59 
GeneralRe: structure equivalant in java Pin
Nagy Vilmos6-Oct-10 2:08
professionalNagy Vilmos6-Oct-10 2:08 
GeneralRe: structure equivalant in java Pin
David Skelly6-Oct-10 4:25
David Skelly6-Oct-10 4:25 
GeneralRe: structure equivalant in java Pin
trioum6-Oct-10 4:58
trioum6-Oct-10 4:58 
GeneralRe: structure equivalant in java Pin
trioum6-Oct-10 6:22
trioum6-Oct-10 6:22 
GeneralRe: structure equivalant in java Pin
David Skelly6-Oct-10 6:59
David Skelly6-Oct-10 6:59 
That's because you are serializing the whole Foo object, which is not what you want.

I'm not going to write the whole thing for you but I think I would make Foo look something like this:

public class Foo {

  public char one;
  public char two;
  public String buffer;
  ... etc ...

  public String toExternalForm() {
    StringBuilder sb = new StringBuilder();
    sb.append(one);
    sb.append(two);
    sb.append(buffer);
    ... etc ...
    return sb.toString();
  }

}


Then to use it:

foo.one = 2;
foo.two = 3;
foo.buffer = "something";
bw = new BufferedWriter(...etc...);
bw.write(foo.toExternalForm());
bw.flush();


That's basically it, you can look up BufferedWriter and whatever else you need and you might want to be a bit more intelligent about handling nulls. (I am using char instead of int in the class Foo because if we use int then StringBuilder would give us 23something which is not what you want, if I have understood correctly.)
GeneralRe: structure equivalant in java Pin
trioum6-Oct-10 22:34
trioum6-Oct-10 22:34 
QuestionRe: structure equivalant in java Pin
David Crow7-Oct-10 10:00
David Crow7-Oct-10 10:00 
QuestionAlarm Clock Help Pin
Autunmsky224-Oct-10 17:32
Autunmsky224-Oct-10 17:32 
AnswerRe: Alarm Clock Help Pin
Richard MacCutchan4-Oct-10 22:09
mveRichard MacCutchan4-Oct-10 22:09 
AnswerRe: Alarm Clock Help Pin
TorstenH.5-Oct-10 3:08
TorstenH.5-Oct-10 3:08 
Questionkey word 'this' Pin
Tichaona J1-Oct-10 5:32
Tichaona J1-Oct-10 5:32 
AnswerRe: key word 'this' Pin
Nagy Vilmos1-Oct-10 5:41
professionalNagy Vilmos1-Oct-10 5:41 
GeneralRe: key word 'this' Pin
Luc Pattyn2-Oct-10 14:28
sitebuilderLuc Pattyn2-Oct-10 14:28 
AnswerRe: key word 'this' Pin
Neo101011-Oct-10 12:45
Neo101011-Oct-10 12:45 
AnswerRe: key word 'this' Pin
Dave Doknjas2-Oct-10 13:31
Dave Doknjas2-Oct-10 13:31 
AnswerRe: key word 'this' Pin
jwintermute5-Oct-10 5:11
jwintermute5-Oct-10 5:11 
AnswerRe: key word 'this' Pin
RaviRanjanKr8-Nov-10 17:51
professionalRaviRanjanKr8-Nov-10 17:51 
Questionprinting jtextpane silently Pin
ndiga29-Sep-10 22:58
ndiga29-Sep-10 22:58 
AnswerRe: printing jtextpane silently Pin
TorstenH.5-Oct-10 3:13
TorstenH.5-Oct-10 3:13 
Questionprinting multiple items on the same paper Pin
ndiga29-Sep-10 22:56
ndiga29-Sep-10 22:56 
Question"missing return statement" error [Solved] Pin
Skippums29-Sep-10 8:33
Skippums29-Sep-10 8:33 
AnswerRe: "missing return statement" error Pin
Skippums29-Sep-10 9:25
Skippums29-Sep-10 9:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.