Page 10 of 34 FirstFirst ... 7891011121320 ... LastLast
Results 91 to 100 of 335
  1. #91

    Default Re: Java Programming


    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();

  2. #92

    Default Re: Java Programming

    Quote Originally Posted by godCode
    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 overwrite

  3. #93

    Default Re: Java Programming

    ^^^ 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.

  4. #94

    Default Re: Java Programming

    koan man gud guys, iyang implementation kay using serialization man gud!! so, kinahanglan jud nga mo gamit ka ug ObjectOutPutStream.. unsaon mana??

  5. #95

    Default Re: Java Programming

    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.

  6. #96

    Default Re: Java Programming

    Use this File...

    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;
      }
      
    }
    To save the object state...

    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....
    	   }
    try bai...

  7. #97

    Default Re: Java Programming

    Quote Originally Posted by boxingfan529
    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.
    Bitaw! good point!

    @jerx d great: Para asa na ni nga program? Para save state ra man ni sa Object ang outputStream.writeObject(param);

  8. #98

    Default Re: Java Programming

    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??

  9. #99

    Default Re: Java Programming

    Quote Originally Posted by jerx d great
    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...
    Code:
    public class HerdOfAnimals implements java.io.Serializable {
    
      private Animal animal[];
    
      public void setAnimal(Animal animals[]) {
       // put some array of animals here...  
    }
    
    }
    then..

    Code:
    HerdOfAnimals herdOfanimals=new HerdOfAnimals[]
    herdOfanimals.setAnimal(Animal animals[]); // ikaw na'y bahala diri
    outputStream.writeObject(herdOfanimals);
    Disadvantage:
    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?

  10. #100

    Default Re: Java Programming

    tanx bro, by the way i'm a student! sa carbon!(usjr)..

  11.    Advertisement

Page 10 of 34 FirstFirst ... 7891011121320 ... LastLast

Similar Threads

 
  1. JAVA PROGRAMMING *****
    By bardnekom in forum Programming
    Replies: 20
    Last Post: 04-18-2013, 12:51 PM
  2. MOVED: JAVA PROGRAMMING *****
    By vern in forum Software & Games (Old)
    Replies: 0
    Last Post: 03-23-2008, 02:43 AM
  3. Java programming help pls...
    By mr_gwen in forum Programming
    Replies: 6
    Last Post: 11-03-2006, 12:30 AM
  4. nid help..java programming
    By ronninalpha in forum Programming
    Replies: 3
    Last Post: 09-13-2006, 07:55 PM
  5. MOVED: Java Programming
    By BadDudes in forum Software & Games (Old)
    Replies: 0
    Last Post: 04-28-2006, 12:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top