Thursday, February 20, 2014

Simple File Handling System

Here are the steps that I made in creating my Simple File Handling System.

          For the main class, I used the JFrame form. The following codes composed the main methods of my file handling system which include the Writing, Reading and Deleting the entire file.

____________________________________________________________________

         Below is the design that I formulated in JFrame form. The Palettes that I used are also indicated below.

          In addition, I created another class (for the Reading function) within the main class above. For reference, here are the codes:

____________________________________________________________________

package textfiles;


import java.io.IOException;

import java.io.FileReader;

import java.io.BufferedReader;



public class Readfile {   

      private String path;   

      public Readfile(String file_path){       

      path=file_path;          

}      

int numberOfLines = 4; 

int readLines() throws IOException{       

      FileReader file_to_read = new FileReader(path);                   BufferedReader bf=new BufferedReader(file_to_read);               String aLine;              

      while (( aLine = bf.readLine()) != null){    

            numberOfLines++;}  bf.close();  return numberOfLines;

       }
public String[] OpenFile() throws IOException {                         FileReader fr =new FileReader(path);      
                        BufferedReader textReader = new BufferedReader(fr);              String[ ] textData = new String[numberOfLines];                  int i;                   

        for (i=0; i < numberOfLines; i++) {                     

          textData[ i ] = textReader.readLine();

         }                   

textReader.close();return textData;
   } 

}

____________________________________________________________________

          Next, I also created another class for the Writing function. I still located this in the main class. The codes are as follow:

____________________________________________________________________

package textfiles;


import java.io.FileWriter;
import java.io.PrintWriter;
import java.io.IOException;

public class WriteFile {
    private String path;
    private boolean append_to_file=false;
    
    public WriteFile(String file_path){
        path = file_path;
    }
    
    public WriteFile(String file_path, boolean append_value){
            path = file_path;
            append_to_file=append_value;
    }
    public void writeToFile( String textLine ) throws IOException {
        FileWriter write = new FileWriter (path, append_to_file);
        PrintWriter print_line = new PrintWriter(write);
        
        print_line.printf("%s" + "%n", textLine);
        print_line.close();
    }

    }

____________________________________________________________________

      The organization of my project package  is shown in the highlighted box below:


      Finally, the output of my program is:
____________________________________________________________________

THANK YOU FOR READING!!! :) :) :)

(Comments, suggestions and reactions are welcomed and will be highly appreciated.)
   ____________________________________________________________________



Wednesday, February 5, 2014

Unexpected Yet Planned

We treasure momentous happenings of our lives way more than how we treasure our prized possessions. It’s for the reason that happy moments can last for a lifetime while possessions can be taken away from us in even as fast as snap of a finger or a blink of an eye.


          It was an ordinary day. A week before the most awaited Christmas vacation would come. I was sitting on the bamboo-made couch of our small-yet-conducive-for-working office when it happened that an idea of having an adventurous vacation came to my mind. It made me realize that it would be exciting for me to have it since I had not experienced it yet even once in my entire existence on Earth.

          For a moment, I asked myself, who my company would be, when it would be and where we would go. I thought for about how many minutes of the possible places to go and persons to be with in this exciting activity until Kimber, one of my officemates, came inside the office. I already knew that she’s living far from this city and it would be better if that’s the case to hold the activity so I suggested my plan to her.

          With the feeling of excitement, she agreed and we talked about some things for it to be finalized.

          Days passed and the Christmas vacation had started to be the rest days of the students. I seldom texted my officemates who showed their interests on the plan for I assumed that they would join. As another couple of days passed, some of my officemates decided not to join due to various reasons. Since I was the one who initiated this outing, I just assigned and texted them what to do, what to bring and where to go. Until December 27, our planned day to have this activity, came. It would really be pursued. I was in great excitement and maybe same is true with the rest of my company.

          We all met up at the crossing of Brgy. Tayak in Siaton. As I counted the participants, we were fourteen. I was amazed that it would reach that number. After a while of preparation for a very long walk since we already had an idea from Kimber that it would be almost two-mile walk from the highway, we already started the walk. Kimber told us that we were going to traverse the shortest possible way of our journey. As we went along, I thought that our walking experience there would take forever since it looked like it’s endless. We had passed three rivers and countless meadows. We had our ways up and down. Some of my officemates almost looked like tired, rugged dogs that their tongue almost hanged out of their mouths. But as what others say, “In the mountain of sacrifice, there’s a fountain of paradise” and it was indeed an accomplishment as we reached the few decades old and two-storey house of Kimber’s grandma, Lola Monica, where we would spend our adventurous experience for two days and a night.




          Our stay there was full of meaningful moments. We had our swimming activities in the attractive river of Canaway. But before we reached that river, we still had to lose some calories for another mile-long walk. Aside from that, we had experienced life living far from luxurious materials and the like. No electricity. No computer. No television and other electronic materials for entertainment except from the battery-operated radio of Lola Monica, the Dama board and bottle caps of Kimber’s uncles and the Scrabble set of her aunts. These were their only entertainment yet they don’t get bored of living with these for almost lifetime. We really experienced the feeling of living in a simplest way opposite to the world’s advancements. This made me realized how peaceful it would be living opposite to the city life!






          As we were about to leave on the second day, some of my officemates decided to visit our Assoc’s house in Bayawan and spend a night for they said it’s their fiesta in their locality. At first, I was in great hesitation of going with them because I was not able to tell my Mama about it and I only brought limited penny for it was already vacation. However, at the end of the day, I just found myself riding with four of my officemates going to Bayawan City. This is where “unexpected yet planned’ experience begins.

          I was with Evram, Jelur, Leo and Rio. We reached Assoc’s dwelling with tired bodies and sleepy eyes yet we still managed to smile in a “chukarap” way as what they call it. Another meaningful and awesome experiences filled our unexpected, additional vacation. After we had our dinner, we first decided to visit and take endless selfie photos using Jelur’s digital camera with the colorful Belens displayed in the plaza of Bayawan as what we were used to do since we join TN. We never cared about what other people might say for we were very concerned about the documentation of this once-in-a-lifetime experience and especially it was the first for Rio, Jelur and Leo to be in the city.










          After giving a few poses for the flashes of the camera, we ended up walking on the scenic boulevard of the city, which is, based on what Evram told us, the longest boulevard in Asia. It was a high-privilege for us to walk in this renowned boulevard therefore we didn’t waste any moment of visiting it. We wished to walk until the end of the boulevard but due to the body pain that we could not resist any longer, we decided to go to our next destination riding on a pot-pot. It was really fun riding in that bicycle with sidecar however, I got pity to the driver since he was carrying us which is to think we were thrice as heavier as his actual weight.

          Without noticing, we reached the children’s playground, our planned next destination. As I saw the various playing equipment, I realized that I really missed my childhood years. Not minding the feeling of shame about what others might think, we played first with the slide located in the middle part of the playground. As I took a slide, my childhood years really flashed back in my mind. Good thing, we didn’t had much rivalry with other kids while playing there since it’s already past nine in the evening. Aside from the slide, we played on the quite-long tunnel with slide on its end, little horse ride with spring on its feet, lever and swing. That night ended with happy memories reminiscing our past childhood years.

          The next day, Evram, told us to visit the Habhaban Cave and Falls in their locality in Malabugas, Bayawan City. Without any hesitation, we agreed on this another unexpected plan. However, Assoc missed the chance to be with us since her mother did not let her to go so we, the Big Five, continued our journey to another experience.







          I thought that this next experience would not be tiring and it would just be smooth. However, what I was actually expecting was wholly opposite to what happened. We traverse our way to Habhaban Cave and Falls with almost similar distance as what we traveled going to Lola Monica’s house. The difference was, the mountainside where we had to walk was steeper. We also lost more calories before we reached the beautiful and mysterious-like Habhaban Cave. Looking at the façade of the cave, I found it very creepy to get inside it without knowing the nature of that cave. There were a lot of what if’s that scared me out but since Evram assured that he knew and he’d already gone inside, the fear was somehow diminished. We brought some dried palm of coconut to lighten our way inside the cave since it was too dark even if the sun was shining out so bright outside.

          As we got inside, another fear entered my feeling. Since I have claustrophobia, I could really hear the fast beating of my heart as if it really wanted to burst out. After the thrilling entrance of the cave where we saw the weird-shaped stalactites, I had freely released my breath as we reach the portion of the cave with very huge space that has an ambiance like the Cathedral.

          After a few minutes, Evram, Rio, Leo and Jelur decided to proceed to the smaller part of the cave where the water can already reach a person’s chin while standing and the stalactite were already touching the forehead.

          I was really scared to be with them inside that smaller part because I might be attacked by my phobia and I could hardly breathe. They really pursued their plan to get inside that part and as I was about to go nearer the other smaller entrance, my mind prevented my body to get inside it which I couldn’t resist.

          I just told them that I would just wait for them in the Cathedral-like space of the cave near the bonfire that we set. As they get farther, I couldn't hear their voices anymore which scared me to death not because I was alone in that big, dark area but because there might be something wrong that happened to them. I just say a little prayer and guidance from up above and I just helped myself to keep calm.

           A few silent moments passed and I could now hear their voices so I was rest assured. They came out of the smaller portion of the cave. I thought they would tell me something awesome about that next portion of the cave but I was disappointed when they shared their death-defying experience in it due to the narrow space and high water level.

          I told myself "what if I really continued to be with them, my family might be mourning now." The feeling of guilt came into my mind because I was not able to tell the truth about my Mama to where I was going. We just saved that adventurous moment to the list of our once-in-a-lifetime experiences. It was fulfilling for my part as we went out of the cave that I had faced my fear.

          The next thing we did later that day was we went to the house of Leo in Cilipapa, Hinoba-an, Negros Occidental riding in the most-requested travel vehicle of Negros Island and Cebu, the Ceres Bus. 

          As the time my right foot touched the loamy soil of that place, I had freely released my breath and said, "At last naka-abot na jud kog Negros Occidental." since it was my first time in that place.

          Well, that's not the end of our journey! For us to really savor the  moment, we never failed to explore the sightings of Cilipapa even if the world there at that time was already as dim as a closed closet. We had reached the Elementary school of Leo wherein it was coincidentally the first reunion of his childhood school.




              After two hours of walking with no directions, we decided to let our body rest.
          The next morning, we took few hours visit to the beautiful beach of the place. And this how their beach looked like:











          Other than that, we still managed to come up with the decision of visiting the lot of Leo's family in the steep mountains for us to be refreshed by the healthy juice of coconut. I was thinking that the length of what we were going to take was not as far as what we had to Kimber's house from the Tayak Crossing. But again, for the second time, I was wrong. It was indeed doubled as to what I thought it was. It was almost 3 miles away from Leo's house. To give you an image, you could really see the mountain that you were going to surpass if you were there with us. I think I lost more than a glass of sweat before we reached the golden place that we were aiming for.
          Anyway, fast forward, we had what we planned to have. We had tasted the delicious buko juice. Thanks to Rio who climbed up the coconut tree for us. 
            Aside from the sweet buko juice, I was also amazed to the natural spring in the small nearby river. With the feeling of curiosity I tried to taste it, since according to them, it's clean and safe to drink-for short, it's potable. As I tasted it, it really tastes safe [as if I know how safe tastes like].
            We joyfully wasted our time there for about two hours before we left that place. As we were having our way back to Leo's house, it seemed that the length of the way became shorter. Thanks, to reverse illusion.
             It was exactly 4:35 pm when I and Jelur finally decided to have our way back to our home sweetie homes riding the yellow-themed Ceres bus. And I finally arrived home at 8:00 pm. And this ends our UNEXPECTED YET PLANNED adventures. 

          These experiences are indeed unexpected yet we planned for it to make this moment last like forever. These maybe tiring for our earthly bodies yet we felt fulfilled as it was included in the list of unforgettable events of our lives.