Free Essay

Buffer Writer

In:

Submitted By Lvl1PwrUp
Words 334
Pages 2
//Example reads in employee data from user
//data is not stored in an Employee object but is written into files using
//Formatter
//PrintWriter
//BufferedWriter
import java.io.FileWriter; import java.io.BufferedWriter; import java.io.PrintWriter; import java.io.File; import java.util.Formatter; import java.util.Scanner;

class FileWriterDemo {

public void buffEmployeeFileWriter() throws Exception { String fName; String lName; int id; boolean quit = false; boolean response = true; Scanner console = new Scanner(System.in); Scanner input = new Scanner(System.in);

Formatter output = new Formatter("EmployeeFormatter.txt"); //opens the file for editing FileWriter file = new FileWriter("EmployeePrintWriter.txt"); PrintWriter print = new PrintWriter(file); //turn on append flag for EmployeeBufferedFileWriter.txt FileWriter fwriter2 = new FileWriter(new File("EmployeeBufferedFileWriter.txt"), true); BufferedWriter bfw = new BufferedWriter(fwriter2);

try { while (quit != response) { System.out.print("Enter Employee First Name:\n"); fName = input.next();

System.out.print("Enter Employee Last Name:\n"); lName = input.next();

System.out.print("Enter Employee id:\n"); id = input.nextInt();

//Example using Formatter System.out.println("Writing out using Formatter\n");

System.out.printf("%s %s %d\n", fName, lName, id); //System.getProperty("line.separator") used for newline output.format("%s %s %d", fName, lName, id); output.format("%s", System.getProperty("line.separator"));

//Example using PrintWriter System.out.println("Writing out using PrintWriter\n");

//Notice how \n looks inside your file. //System.getProperty("line.separator") which was used in the Formatter //example produces and accurate newline. \n does not //Look on line 47 for an example. print.format("%s %s %d\n", fName, lName, id);

//Example using BufferedWriter System.out.println("Writing out using Buffered FileWriter\n");

System.out.print(lName + " " + fName + " " + id + " " + "\n");

bfw.write(lName + " "); bfw.write(fName + " "); bfw.write(id + " "); bfw.write(System.getProperty("line.separator"));

System.out.println("Do you want to enter more Employee data? Enter true/false"); response = console.nextBoolean(); } //while

//close all files used output.close(); file.close(); bfw.close();

} catch (Exception e) //catch in case the file has issues {

System.err.println("File problems: " + e.getMessage()); System.exit(1); }

}
}

Similar Documents

Free Essay

Term

...LOVELY PROFESSIONAL UNIVERSITY HOME WORK – I DOA: 9/7/2012 DoS: 9/17/2012 ------------------------------------------------------------------------------------------------------------------- Assignment COURSE- Modern Web Programming Tools and Techniques-I COURSE CODE- CAP618T SUBMITTED BY: SUBMITTED TO: Anil Kumar Miss. MANDEEP KAUR Roll-A24 Reg. - 11013165 Sec- D1R05 Q: 1 Take a JavaBeans Object named “Profession” with properties domain and expertise. Show the use of all 4 scope types on this object. Ans:- You just need to create a domain object as a JavaBeans property and the corresponding getter and setter methods. The framework will automatically initialize the domain object and transfers the form data. The UserAction class contains the following code. Public class UserAction extends ActionSupport { Private User user; Public UserAction() { Public String execute() { Return SUCCESS; } Public User getUser() { Return user; } Public void setUser(User user) { this. user=user; } } To refer the user attributes like name, age etc. we need to first get the user object and then access its properties. For example to access the user's age in the Action you need to use the following syntax. getUser().getAge(); public class User...

Words: 1247 - Pages: 5

Free Essay

Nt1210

...Labs Unit 4 Labs NT1210 8/4/14 Unit 4 Labs Lab Review: 4.1 – Page: 82 and 83 1. To eliminate the crossover issue, lower the amount of equipment and cost. Simplify a network. 2. To increase the maximum distance for a signal. If put after the maximum distance the signal may degrade. 3. The connection and processing speed. It also depends on the number of connections the computer or laptop will allow. Lab Review: 4.2 – Page: 85 1. A. Bend Radius: The minimum radius that a fiber optic cable can be bent without loss of light or impairment. A general rule that it be no less than 15 times the cable diameter B. To not affect a signal sent down the line. 2. The core/Glass Filament, Cladding, Buffer, Strengthener and Outer Jacket. Lab Review: 4.3 – Page: 90 1. Ease of installation, lack of certified fiber optic specialists and changes to the physical design of the network later on. 2. By limiting the devices needed depending on the distance and need of each network. Verify the number of access points needed before the start. Lab Review: 4.4 – Page: 95 1. By selecting a specific layer and testing the health you can definitively say the problem lies either below or above that layer. Example: test the Transport layers health if it is ok you know the problem is in the Application layer. 2 A. B. If the cable is damaged in any way it should be checked. -----------------------...

Words: 255 - Pages: 2

Free Essay

Buffering Work and Family Conflict

...there for your entire family. Both work and family come with obligations and it is often difficult to prioritize between the two as both are very important and rely on each other. There are certain buffers that help dissipate work and family conflict. One of them is family composition. There is a lot covered under a family’s composition. Having close family and friends nearby can help a single working mother or father or even dual working parents juggle their work and family lives. Extra hands on deck are always a plus with busy families. Depending on the ages of the children of a family, younger children tend to provide more stressors while older children who need less are more stable and can do a lot for themselves which relieves potential stress off the parents. If both parents work, having set chores for each of them is a good way to even the playing field making sure neither parent is more overloaded than the other. A housekeeper would also be a great option to take some of that stress of their shoulders. The traditional gender roles are where the husbands work the long hours and the wives stay at home and take care of the children and do the housework. Sometimes conflict is created because of the work stress that the husband goes through where the wife does not. A good buffer for this is for the wife to enter the workforce as well, even if it’s simply...

Words: 807 - Pages: 4

Free Essay

Internet and Information Paper

...internet has so much information for many resources from around the world, it is crucial to develop skills to accurately access the information you are reviewing. When you use sources at a library, each one has been reviewed and evaluated to ensure the material presented is authentic and not fabricated. When one uses the internet, none of these screens are applicable. In essence there are no buffers with the information available and anyone can post regardless of its truth or not. The main way to ensure the information one is reviewing is credible is to use the following steps: • Authorship • Publisher • Bias • Accuracy of details With verifying Authorship, one should be researching the person who wrote the article especially if it is an author that the reader does not recognize. Also, in doing your research of the author, how are they reviewed by their peers and are they linked to some other site or article that you trust? In assessing the Publisher or better known as “Publishing Body” this gives the reader a base of comfort in knowing that the manuscript from the writer has undergone several levels of examination to assess value to the writings. You...

Words: 489 - Pages: 2

Premium Essay

Buffer

...Preparation of Buffers for Use in Enzyme Studies (by G. Gomori) The buffers described in this section are suitable for use either in enzymatic or histochemical studies. The accuracy of the tables is within ± 0.05 pH at 23 ºC. In most cases the pH values will not be off by more than ± 0.02 pH even at 37 ºC and at molarities slightly different from those given (usually 0.05 M). The methods of preparation described are not necessarily identical with those of the original authors. The titration curves of the majority of the buffers recommended have been redetermined by the writer. The buffers are arranged in the order of ascending pH range. 1. Hydrochloric Acid-Potassium Chloride Buffer. Stocks solutions A: 0.2 M solution of KCl (14.91 g in 1 L) B: 0.2 M HCl 50 mL of A + x mL of B, diluted to a total of 200 mL x 97.0 78.0 64.5 51.0 41.5 33.3 26.3 20.6 16.6 13.2 10.6 8.4 6.7 jun 14, 2004 pH 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 Pag.1 2. Glycine-HCl Buffer. Stocks solutions A: 0.2 M solution of glycine (15.01 g in 1 L) B: 0.2 M HCl 50 mL of A + x mL of B, diluted to a total of 200 mL x 5.0 6.4 8.2 11.4 pH 3.6 3.4 3.2 3.0 x 16.8 24.2 32.4 44.0 pH 2.8 2.6 2.4 2.2 3. Phthalate-Hydrochloric Acid Buffer. Stocks solutions A: 0.2 M solution of potassium acid phthalate (40.48 g in 1 L) B: 0.2 M HCl 50 mL of A + x mL of B, diluted to a total of 200 mL x 46.7 39.6 33.0 26.4 20.3 pH 2.2 2.4 2.6 2.8 3.0 x 14.7 9.9 6.0 2.63 pH 3.2 3.4 3.6 3.8 4. Aconitate Buffer. Stocks solutions...

Words: 2459 - Pages: 10

Premium Essay

Sosc 224

...Soil Fertility, Evaluation and Nutrient Management Major contributors to increased agricultural production * Fertiliser use * Plant breeding * Other cultural practises * (planting date, crop density, rotations etc) * Weed and pest control * Irrigation Future Challenges * World population continues to grow * Decrease in productive land due to industrial, residential, transport use and soil degradation * 2 degree increase in temperature over 100 years * Extreme weather conditions * Advances in agricultural production needed to feed population Factors for crop yield * Plant growth and yield are affected by over 50 factors * We cannot control many of the climate factors * Soil and crop factors can be managed for maximum and economical production * Table: major factors affecting yield potential The Law of the minimum * Crop yield is determined by the most limiting factor * Crop yield can only be increased by eliminating the most limiting factor * Yield cannot be increased by increasing the supply of other nutrients and factors * Challenge is to identify the limiting factors and eliminate them Sources of mineral nutrients for plant uptake * Plants take up mineral nutrients from soil solution * Amounts of nutrients in solution are small * Soil solution nutrients are replenished by there in soil/solid form Table: Nutrient dynamics in the soil that affect nutrient supply to plants The intensity...

Words: 283 - Pages: 2

Free Essay

Mda Assay

...CHAPTER 3: METHODOLOGY 3.1 Study Design This research is an experimental study which was conducted to investigate the effectiveness of treatment of Cassia alata as antioxidant effects in cardiovascular system of hyperglycemic rats. The antioxidant activity was tested from the leaf of Cassia alata using its aqueous extract. For this study, 30 Wistar rats weighing between 180 to 200g were used. They were housed in standard cages in a room with a 12 hour light/dark cycle and 50 to 60% relative humidity at a temperature of about 30°C. The animals had fed with standard food and water without limit. This study was conducted in two groups of streptozotocin (STZ) induced diabetic rats in which each group will consist of 15 rats. For the first group of STZ induced diabetic rats had fed with Cassia alata aqueous extract for 20 days meanwhile for the second group of STZ induced diabetic rats had fed with normal saline as a negative control for 20 days. The two groups of STZ induced diabetic had divided into 2 batches. First batch of diabetic rats was consisted of 6 rats for both groups while the second batch was consisted of 9 rats for both groups. All of the rats in two groups had fasted for 12 hour before induced diabetic via STZ injection. After an injection, the rats with level of fasting blood sampling (FBS) above 200 mg/dl will take for further investigation. Henceforth, the treatment was began in which the Cassia alata aqueous extract will administer orally after 48 hour diabetic...

Words: 2789 - Pages: 12

Free Essay

C Programming on Linux

...C Programming on Linux What You Need for This Project * A Kali Linux virtual machine. You could use other operating systems too, if they have a C compiler. Writing the hello.c Source Code In a Terminal window, execute this command: nano hello.c The nano editor opens. Type in the program shown below. #include <stdio.h> main() { printf("Hello World!\n"); } Save your file with Ctrl+X, Y, Enter. Compiling hello.c to Create the hello File In a Terminal window, execute these commands: gcc hello.c -o hello ./hello These commands compile the hello.c program, creating an executable machine language file named hello, and run the hello executable. You should see "Hello World!", as shown below. This program works, but it would be nicer if it greeted you by name, and if it put a couple of newline characters after the greeting to make it cleaner-looking. The next version, hello2, will add these features. Writing the hello2.c Source Code In a Terminal window, execute this command: nano hello2.c The nano editor opens. Type in the program shown below. #include <stdio.h> main() { char name[10]; printf("What is your name?"); scanf("%s", name); printf("Hi, %s\n\n", name); } ...

Words: 1293 - Pages: 6

Free Essay

The Properties of Buffers

...General Chemistry II Professor: Dr. Yang Yang Turned in: April 9, 2014 Experiment #6 The Properties of Buffers Abstract In this experiment the pH of fours solutions was recorded and identified as acidic, basic, or neutral. A buffer system of 0.10 M ammonium ion (NH4+) and 0.10 M ammonia (NH3). This buffer was made three times: once with equal parts ammonium ion and ammonia, next it was diluted to double the volume, and finally it was prepared with an addition of HCl. The pH was recorded to calculate the Ka and pKa values. The most accurate Ka value recorded was the second from B2 which was 5.13x10-10. Using this Ka value the appropriate volumes of ammonium ion and ammonia were calculated to make a buffer solution with a pH of 8.7. The final volumes were 15.9 mL of ammonium ion and 4.1 mL of ammonia. Part A solution pH acidic, basic, neutral? 0.100 M NaHSO4 1.8 acidic 0.100 M Na2CO3 11.2 basic 0.100 M NH3 10.9 basic 0.100 M NaCI 6.8 neutral Net Ionic Reaction NaHSO4 Na+ + HSO4- + H2O --> Na+ (SO4)2- + H3O+ HSO4- + H2O --> (SO4)2- + H3O+ Na2CO3 Na2CO3 + H2O --> NaHCO3 + NaOH 2Na+ + CO32- + H2O --> Na+ + HCO3- + Na+ + OH- CO32- + H2O --> HCO3- + OH- NH3 NH3 + H2O --> NH4-+ OH- NaCI NaCI + H2O --> H2O + Na+ + Cl- NaCI--> Na+ + Cl- Part B calculations attached on next page Ka Values Part Ka pKa B1 6.3x10-10 9.2 B2 5.13x10-10 9.29 B3 3.98x10-10 8.4 Discussion: All of the Ka values were...

Words: 431 - Pages: 2

Premium Essay

Ph Measurement and Buffer Preparation

...pH Measurement and Buffer Preparation Quilao, M.H., Regua, R., Reinoso, L.A., Rojas, K.J., Sabalberino, E.M. Abstract In this experiment, phosphate buffer solution was prepared and the pH of the buffer and samples were determined through different liquid indicators and the pH meter. Also, the buffer capacity of the prepared buffer solution was calculated. The group was tasked to prepare a 250 mL phosphate buffer solution of pH 8.0 using dihydrogen phosphate ion (H2PO4) and primary sodium phosphate monohydrate (NaH2PO4.H2O). With the aid of 6.0 M HCl and 6.0 M NaOH, the pH of the buffer was adjusted while being recorded by the pH meter until it reached the desired pH. Afterwards, the buffer solution was introduced to Colorimetric Determination which used acid-base indicators. The buffer solution changed to color yellow when Thymol and Methyl red were added, blue when Bromophenol blue and Bromocresol green were included, purple for Bromocresol purple, pink for Phenol red and Phenolphthalein, and orange for Methyl orange. Introduction The measurement of the low concentration of hydrogen ions present in any biological process is expressed as pH. pH is used to measure the acidity and alkalinity of a solution. pH involves ionic activity, making it difficult to accurately predict the pH value of a solution. The pH is also known to greatly affect our biological system and any large changes could be dangerous, which is why there is a buffer present within our systems...

Words: 971 - Pages: 4

Premium Essay

Reading and Technology

...Writing for me was never a struggle, I was just lazy. I learned to write better when I started college. I would practice writing more because I had to. My writing improved and I desired to write more. When a student doesn’t want to write because they feel they can’t, you can’t expect them to try. Writing is hard and messy; it takes will and caring enough to want to write. It’s that more interesting, stimulating and fun when you write about something that captures your interest to get students motivated to write. I’ll start with one good old fashion method, “motivation.” Motivation plays an essential role in developing good writing skills. Teachers want to be able to present students with the materials and tools they need to gain their interest. It’s also important for them to have access to everything they need at their fingertips. What I also think would make a student’s successful at writing is to implement writing workshops daily, into their everyday curriculum. Routines and rituals are set-up for the workshops. This gives them something to look forward too. It’s a way to work out the things that they struggle with, like not getting enough writing or expectations of how much they should write about. They need to grow on those things, motivate them to focus and brainstorm on ideas and get those ideas down on paper. Motivate them to share and reflect on what they write about. Every day, during the beginning of the class, they start with an expectation for the activity, they...

Words: 515 - Pages: 3

Free Essay

Experiences as a Writer

...In the past 5 years, I have been using my opportunities for writing in my work environment. I work in a Mini Medical Health insurance company where I have to communicate with not only my co-workers but the clients. A lot of my writing is done through emails and billing. I also write letters to our patients who are also members, notifying them of any problems regarding their insurance. Another form of writing I do through out the week is discussion questions for my English class and my Math class. The discussion questions are usually about what we learned that week. One example of the discussion questions would be, “How would I improve in my writing”? Another example would be, “How does mathematics affect our lives?” Also, I would respond to one of my classmate’s answer and give them my feedback on what they wrote. I know that writing is used a lot in the business world and that I need to improve in it because I am not very good at writing. It is hard for me to come up with ideas and conclusions. Writing also sometimes is confusing for me when it comes to using certain words in writing. An example would be remembering when to use the words” there” and “their”. One is talking about a place and the other about a group of people, but sometimes I use it incorrectly in my writing. What I would do in that situation is look it up in a dictionary to make sure I use the correct word in the sentence. There was once a time when I wrote an email to my boss and I did not proof...

Words: 441 - Pages: 2

Premium Essay

Karim

...understand | استنتج | 5 | explicit | specific | صريح | 6 | frequently | Much , a lot | كثيرا | 7 | illustration | clarification, explanation | توضيح | 8 | critique | criticism | نقد | 9 | generalization | popularization | تعميم | 10 | desirable | eligible | مرغوب فيه | 11 | authors | writer, bookkeeper, prosaist | الكتاب | 12 | assignment | task, mission, job | مهمة | 13 | argue | dispute, debate, quarrel, | تجادل | 14 | proposition | suggestion, motion, | اقتراح | 15 | mass | Collective, memorial prayer | كتلة | 16 | perception | understanding, grasp | الإدراك | 17 | influenced | affected | متأثر | 18 | apparent | visible, obvious, manifest | واضح | 19 | theoretical | abstract, notional | نظري | 20 | approaches | oncoming, access | المناهج | 21 | argument | excuse, pretext, | حجة | 22 | coherent | solid, concrete | متماسك | 23 | demonstrate | explain, expound, | شرح | 24 | | | | 25 | | | | 26 | | | | 27 | | | | The Explanatory Synthesis The purpose of this handout is to describe briefly the purpose of the explanatory synthesis essay and to provide you with some writing suggestions. In the explanatory synthesis, writers divide a subject into its component parts and present them to the reader in a clear and orderly fashion. You will present the facts objectively, without judgment. Your purpose is to use your sources to inform your readers. In developing a thesis for your explanatory synthesis, base your thesis on...

Words: 836 - Pages: 4

Free Essay

Experiences as a Writer

...Experiences as a writer My experience as a writer is very limted. As a mechanic and seeing that this is my first time attending college I do not have much experience. The only time have to dedicate to writing is when I’m off from work. I am usually writing about my feelings for my loved ones in a journal. When at work I am required to write reports on the equipment and the functions of the machines. At school I am allowed to expand my knowledge for writing. My feelings towards writing are mixed. On one hand I enjoy writing but, because of my lack of knowledge and my busy schedule I do not have time to fully dedicated myself to it. To me in order to write u have to have a feeling towards it, and truly understand what you are doing. I believe that you cannot simply jump into writing it has to be learned over time and practice in order to become a good writer. My experience from writing comes from my journal entries that I try to write in every day. I believe that is going to help me become more adjusted to writing in a class room. My bad experiences with writing come from when I was in high school. I was not a very good writer and it showed in my grades. I do believe it’s because of I lacked the passion to write. So that taught me that whenever I pick a topic to write about it has to be sometime that I could relate to as closely as...

Words: 268 - Pages: 2

Premium Essay

Writing Purpose

...Imagine reading a poorly written review of a movie that you would like to see this weekend. You cannot follow the characters, action, or conflict because the author of the review rambles on and on. Without clear paragraphs, this review will likely lose your interest, and you may skip the movie altogether! When you are the writer, it is helpful to position yourself as a reader. Ask yourself whether you can focus easily on each point you make. Effective writers use a single paragraph for each new idea they introduce. Paragraphs separate ideas into logical, manageable, and distinct units. Each paragraph focuses on only one main idea and presents coherent sentences to support that single point. Because all the sentences in one paragraph support the same point, a paragraph may stand on its own. Each paragraph is shaped by Purpose: the reason why the writer composes the paragraph. < Tone: the attitude the writer conveys about the paragraph’s subject. < Audience: the individual or group whom the writer intends to address. < Content: the written material in the paragraph. < 174 WRITING FOR SUCCESS To create longer assignments and to discuss more than one point, writers group together paragraphs and link them together with transitions. The assignment’s purpose, audience, and tone dictate the content, which determines what paragraphs cover and how each will support a main point. The main point of the paragraph is the message you want to share with the...

Words: 11739 - Pages: 47