Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. import java.io.File;
  2. import java.io.FileNotFoundException;
  3. import java.io.PrintWriter;
  4. import java.util.Scanner;
  5.  
  6. public class HW1_1 {
  7.  
  8. public static void main(String args[]) throws FileNotFoundException {
  9. //scan in the new file and place it in a string
  10. Scanner scanner = new Scanner(new File("C:\\Users\\celery\\Documents\\workspace1\\sampys\\HW1_1.java"));
  11. String text = null;
  12. while (scanner.hasNextLine()) {
  13. text=scanner.nextLine();
  14. }
  15. //close my scanner
  16. scanner.close();
  17.  
  18. //create output file and write into it
  19.  
  20. PrintWriter out = new PrintWriter(new File("HW1_1.java.txt"));
  21.  
  22.  
  23. for(int i=0; i<text.length(); i++){
  24. out.printf("%03d",text.charAt(i));
  25. }
  26.  
  27. out.close();
  28.  
  29.  
  30. }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement