Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.IOException;
- import java.io.RandomAccessFile;
- import java.util.Scanner;
- public class primer {
- public static void skokni(File in, long pozicija) throws IOException {
- File out = new File("C:\\Users\\elisp\\Desktop\\out\\treta.txt");
- RandomAccessFile rf = null;
- RandomAccessFile wf = null;
- if(in.exists()){
- File[]subfiles = in.listFiles();
- for (File file : subfiles) {
- System.out.println("File" + file.getName());
- try
- {
- rf = new RandomAccessFile(file, "r");
- wf = new RandomAccessFile(out, "rw");
- int c;
- rf.seek(pozicija);
- while((c=rf.read())!=-1)
- {
- System.out.println((char)c);
- wf.write(c);
- pozicija++;
- }
- }
- catch (Exception e) {
- // TODO: handle exception
- }
- finally {
- if(rf !=null)
- rf.close();
- if(wf !=null)
- wf.close();
- }
- }
- }
- }
- public static void main(String[] args) throws IOException {
- File in = new File("C:\\Users\\elisp\\Desktop\\in");
- skokni(in, 3);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement