Embed
Email

Text-Files.ws

Document Sample

Shared by: xiuliliaofz
Categories
Tags
Stats
views:
0
posted:
11/6/2011
language:
English
pages:
1
//WRITING

import java.io.FileWriter;

import java.io.PrintWriter;



//READING

import java.util.StringTokenizer;

import java.io.FileReader;

import java.io.BufferedReader;

import java.io.File;



import java.io.IOException;



public class FileExTester {

public static void main( ) throws IOException

{

readFromFile( );

writeToFile("R. Harris" );

}

//++++++++++++++++++++++++++++++++++++++++++++++++++++++++READ FROM+FILE++++++

private static void readFromFile( ) throws IOException

{

File inF = new File("H:\\M359\\JAVA\\Files\\input.txt"); //File path access!

if(inF.exists())

{

FileReader reader = new FileReader(inF);

BufferedReader in = new BufferedReader(reader);



String inL; //Entire Line!

StringTokenizer token; //Individual word or number within the line

do //Ex will have 4 lines -> 1. Name

{ // 2. Tests

inL = in.readLine(); //Read Name. 3. Progs

System.out.println(inL); // Print Name. 4. Hk



for(int i = 1 ; i ");

out.close();

}

}



Other docs by xiuliliaofz
Dreaming
Views: 2  |  Downloads: 0
Maurice White BDSc Melb
Views: 0  |  Downloads: 0
article-7901
Views: 0  |  Downloads: 0
Application - City of Laramie
Views: 0  |  Downloads: 0
Project Outline - TeacherWeb
Views: 0  |  Downloads: 0
NSSE EDUCATION
Views: 0  |  Downloads: 0
me344_f03
Views: 0  |  Downloads: 0
Experiment_11a
Views: 0  |  Downloads: 0
CHAPTER 16
Views: 0  |  Downloads: 0
Distributed Data Base Systems
Views: 3  |  Downloads: 0
By registering with docstoc.com you agree to our
privacy policy

You are almost ready to download!

You are almost ready to download!