Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. import java.io.File;
  2. import java.io.IOException;
  3. import java.io.RandomAccessFile;
  4. import java.util.Scanner;
  5.  
  6. public class primer {
  7.  
  8. public static void skokni(File in, long pozicija) throws IOException {
  9. File out = new File("C:\\Users\\elisp\\Desktop\\out\\treta.txt");
  10. RandomAccessFile rf = null;
  11. RandomAccessFile wf = null;
  12. if(in.exists()){
  13.  
  14. File[]subfiles = in.listFiles();
  15. for (File file : subfiles) {
  16. System.out.println("File" + file.getName());
  17. try
  18. {
  19.  
  20. rf = new RandomAccessFile(file, "r");
  21. wf = new RandomAccessFile(out, "rw");
  22. int c;
  23. rf.seek(pozicija);
  24. while((c=rf.read())!=-1)
  25. {
  26. System.out.println((char)c);
  27. wf.write(c);
  28. pozicija++;
  29. }
  30. }
  31. catch (Exception e) {
  32. // TODO: handle exception
  33. }
  34. finally {
  35. if(rf !=null)
  36. rf.close();
  37. if(wf !=null)
  38. wf.close();
  39. }
  40. }
  41. }
  42.  
  43.  
  44.  
  45.  
  46. }
  47. public static void main(String[] args) throws IOException {
  48. File in = new File("C:\\Users\\elisp\\Desktop\\in");
  49. skokni(in, 3);
  50. }
  51.  
  52.  
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement