Kanjut SHELL
Server IP : 172.16.15.8  /  Your IP : 18.119.19.205
Web Server : Apache
System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64
User : apache ( 48)
PHP Version : 7.2.24
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home/thchang/cs440/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/thchang/cs440/Append.java
//
//Assignment 8B
//Name:	Append.java
//
//Author:	Tyler Chang
//Instructor:	Dr. John Wang
//Course:	CS 440
//
//Due: April 1, 2015
//
//Goal:	 Simulate the "append" Linux command.
//		The 1st arg is the source file and
//		the 2nd is the destination file.
//		The destination file is appended with
//		the contents of the source file.
//

import java.util.Scanner;
import java.io.File;
import java.io.FileWriter;

public class Append
{
	public static void main(String[] args)
	throws java.io.IOException
	{
		// setup files and i/o streams
		File src = new File(args[0]);
		File dest = new File(args[1]);
		Scanner input = new Scanner(src);
		FileWriter output = new FileWriter(dest, true);

		// append line by line
		while(input.hasNextLine())
		{
			output.write(input.nextLine() + "\n");
		}

		// destroy writer object
		output.flush();
		output.close();
	}
}

Stv3n404 - 2023