Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.PrintWriter;
- import java.util.Scanner;
- public class HW1_1 {
- public static void main(String args[]) throws FileNotFoundException {
- //scan in the new file and place it in a string
- Scanner scanner = new Scanner(new File("C:\\Users\\celery\\Documents\\workspace1\\sampys\\HW1_1.java"));
- String text = null;
- while (scanner.hasNextLine()) {
- text=scanner.nextLine();
- }
- //close my scanner
- scanner.close();
- //create output file and write into it
- PrintWriter out = new PrintWriter(new File("HW1_1.java.txt"));
- for(int i=0; i<text.length(); i++){
- out.printf("%03d",text.charAt(i));
- }
- out.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement