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

Nt1310 Unit 1 Lab Report

...2.1 Chemicals and buffers 2.1.1 Chemicals Chemicals used were of high molecular biology grade unless specified otherwise. A complete list of chemicals is available in Appendix 1. 2.1.2 Buffers Buffers were prepared with molecular biology grade chemicals. Buffer Composition TE Buffer 10mM Tris-Cl (pH 7.4), 1mM EDTA (pH 8.0) Loading buffer 0.25% bromophenol blue, 40% sucrose TAE Buffer 40mM Tris-acetate, 2mM EDTA 2.2 MEDIA 2.2.1 Great Artesian Basin (GAB) media The medium used for this project was designed to allow the growth of thermophiles and mesophiles that were isolated from the Great Artesian Basin. The media was adjusted to support the growth of both aerobic and anaerobic organisms. The media composition as grams/liter is as follows...

Words: 3778 - Pages: 16

Premium Essay

Chemistry Reactions

...Buffer solutions and common ion effect A buffer solution resists (or buffers) a change in its pH. That is, we can add a small amount of an acid or base to a buffer solution and the pH will change very little. How to calculate pH of buffer solution containing both acid and conjugate base? Dissociation constant definition 1.1 can be rearranged into [pic] or [pic] (note that due to sign change [A-] was moved to nominator). This is so called Henderson-Hasselbalch equation (or buffer equation). It can be used for pH calculation of solution containing pair of acid and conjugate base - like HA/A-, HA-/A2- or B+/BOH. For solutions of weak bases sometimes it s more convenient to use equation in the form [pic]15.3 Two common types of buffer solutions are : (1) a weak acid together with a salt of the same acid with a strong base. These are called Acid buffers e.g. CH3COOH + CH3COONa. (2) a weak base and its salt with a strong acid. These are called Basic buffers. e.g.NH4OH + NH4Cl. Let us illustrate buffer action by taking example of a common buffer system consisting of solution of acetic acid and sodium acetate (CH3COOH/CH3COONa). CH3COOH --- H+ + CH3COO– CH3COONa ---- Na+ + CH3COO- since the salt is completely ionised, it provides the common ions CH3COO– in excess. The common ion effect suppresses the ionisation of acetic acid. This reduces the concentration of H+ ions which means that pH of the solution is raised. Thus, a 0.1 M acetic acid solution has a pH...

Words: 1091 - Pages: 5

Premium Essay

Op-Amps

...Part 4.5 An integrator amplifier is a circuit which output voltage proportional to the time integrator of the input voltage. As the name implies, the function of integrator amplifier is configure to perform the mathematical calculus, integration. Integration is the process to find the area under the graph. Hence integrator amplifier, the output voltage it designed to work responds to the input voltage respect to the time. By applying KCL VinRin=-C(dVoutdt) Vout=-1RC×0tVin(t)dt The integrator also always has a phase shift of +90⁰ to the output voltage. In which, the input voltage of a sine wave will be outputted with a cosine wave and vice versa. The interchanging of capacitor, Cf and resistance, R1 will become a differentiator circuit. ∅= +90°-tan-1(2πRC) As an ideal cases, there are no current can flow into the op-amp. This is due to the grounding at the non-inverting terminal and result in the 0V in the inverting terminal. During the experiment, one of the procedures is to use the dc offset to make sure no dc voltage is in Vin. This is because the input offset voltage is not zero or another word, the supplied voltage work together with AC and DC. Hence, the dc input voltage will be integrated and the output voltage starts to drift. Part 4.6 An op-amp without a feedback resistance is original a difference amplifier. The difference op-amp produces the algebraic difference between the two input signals. Few cases can be done in the difference op-amp. Example like the...

Words: 960 - Pages: 4

Premium Essay

Buffer Lab Report

...Introduction Buffer is a solution that resists a change in pH when bases or acid are added. Solutions that are acidic contain high concentrations of hydrogen ions (H+) and have pH values less than seven. Buffer usually consist of a weak acid, and its conjugate base or a weak base and its conjugate acid. The function of buffer is to resist the changes in hydrogen ion concentration as a result of internal and environmental factor. This buffer experiment is important so that we relies the important of buffer in our life. Besides that, it is also important so that we master the buffer preparation techniques and can conduct the experiment ourselves without anyone to instruct us. Other than that, we got to learn how to operate a pH meter and we...

Words: 1344 - Pages: 6

Free Essay

Spc of Salicylated

...THE PASSAGE OF SALYCILATE INTO YEAST CELLS AIM: Aim of the experiment is to investigate and analyse the effect of pH on the transfer of salicylate across membranes. INTRODUCTION: As Schedule METHOD: As Schedule RESULTS: Test Tube number | Absorbance | 1 | 0 | 2 | 0.171 | 3 | 0.337 | 4 | 0.496 | 5 | 0.598 | 6 | 0.801 | 7 | 1.598 | 8a | 0.46 | 9a | 0.629 | 10a | 0.701 | 11a | 0.899 | 8b | 0.704 | 9b | 0.793 | 10b | 0.830 | 11b | 0.877 | 1. 1.0 x (PCV/100)X0.9= Volume of yeast The PCV= 18% :. 1.0x (18/100)x 0.9 = VY Vy= 0.162 2. Total volume- yeast volume= volume of supernatant :. 3.0ml- 0.162 = 2.838 3. Concentration of salicylate | Sal.concentration | V.S x C.S | Amount of sal. In yeast cells | Conc of sal. Inside yeast | 1 | 0 | 0 | 0 | 0 | 2 | 0.1 | 0.2838 | 1.7162 | 10.59 | 3 | 0.2 | 0.5876 | 1.4324 | 8.84 | 4 | 0.3 | 0.8514 | 1.1486 | 7.09 | 4 | 0.4 | 1.1352 | 0.8648 | 5.34 | 6 | 0.5 | 1.419 | 0.581 | 3.59 | 7 | 1.0 | 2.838 | -0.838 | 5.17 | 4. Volume of supernatant x concentration of salicylate :. 0 x2.838 = 0 0.1 x 0.2838 = 0.2838 0.2 x 0.2383 =0.5876 0.3 x 0.2383 = 0.8514 0.4 x 0.2383 = 1.1352 0.5 x 0.2383 = 1.419 0.6 x 0.2383 = 2.838 5. Amount of salicylate in yeast cells= 2mg-amount of salicylate in supernatant 2mg. ( Please refer to table 2) 6. Concentration of salicylate inside yeast = amount of sal./ V.Y (Please refer...

Words: 321 - Pages: 2