ayaw lang outputStream object gamita...
try kuno diretso ani:
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("theText.txt", true)));
out.println(line1);
out.println(line2);
out.println(line3);
out.close();
ayaw lang outputStream object gamita...
try kuno diretso ani:
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("theText.txt", true)));
out.println(line1);
out.println(line2);
out.println(line3);
out.close();
Sakto! Mao ni akong gamit sad, just change true to false if you want to overwriteOriginally Posted by godCode
^^^ Mas ganahan ko sa outputStream.writeObject(param);. Pero kailangan sad lagi ka mg-buhat og Serialized object, para ma-store ang current state sa Object.![]()
koan man gud guys, iyang implementation kay using serialization man gud!! so, kinahanglan jud nga mo gamit ka ug ObjectOutPutStream.. unsaon mana??
maoverwritten jud na cya bisag lahi iyang object i-save sa file when using .writeObject().
what u can do is create one file for each object to be save.
Use this File...
To save the object state...Code:public class Animal implements java.io.Serializable // Since Serializable na ni siya the state of the instance of this class can be stored na! { private String speciesName; private String population; private String growthRate; /** Creates a new instance of Animal */ public Animal() { speciesName=""; population=""; growthRate=""; } public Animal(String speciesName, String population, String growthRate) { this.speciesName=speciesName; this.population=population; this.growthRate=growthRate; } public void setSpeciesName(String speciesName) { this.speciesName=speciesName; } public void setPopulation(String population) { this.population=population; } public void setGrowthRate(String growthRate) { this.growthRate=growthRate; } public String getSpeciesName() { return speciesName; } public String getPopulation() { return population; } public String getGrowthRate() { return growthRate; } }
try bai...Code:Animal animal=new Animal(); animal.setSpeciesName(tf_speciesName.getText()); animal.setPopulation(tf_population.getText()); animal.setGrowthRate(tf_growthRate.getText()); ObjectOutputStream outputStream = null; try{ outputStream = new ObjectOutputStream(new FileOutputStream("jerus.records")); outputStream.writeObject(animal); // Current object state has been stored. } catch(Exception ex){ //do something.... }
Bitaw! good point!Originally Posted by boxingfan529
@jerx d great: Para asa na ni nga program? Para save state ra man ni sa Object ang outputStream.writeObject(param);
ask lang bai cen, ka usa ra jud ka mo write ana if mo implement ka ana imong program?? dli na jud ka write ug multiple records ana bai??
Pwede man sad ka mag-create parehas ani...Originally Posted by jerx d great
then..Code:public class HerdOfAnimals implements java.io.Serializable { private Animal animal[]; public void setAnimal(Animal animals[]) { // put some array of animals here... } }
Disadvantage:Code:HerdOfAnimals herdOfanimals=new HerdOfAnimals[] herdOfanimals.setAnimal(Animal animals[]); // ikaw na'y bahala diri outputStream.writeObject(herdOfanimals);
Once daghan na ang records mg-lisod naka og delete, insert sa record.
Why not use database? Naa Postgres, MySQL og uban pa nga open source? Ask lang ko Student ka? if yes what school? else what company ka karon?
tanx bro, by the way i'm a student! sa carbon!(usjr)..
Similar Threads |
|