Всем привет. Решил сделать личный проект.
Начал тестить, и почему выдает ошибку:
Exception in thread "main" java.nio.file.AccessDeniedException: D:\hehe.pdf
at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:230)
at java.nio.file.Files.newByteChannel(Files.java:361)
at java.nio.file.Files.createFile(Files.java:632)
at mainClass.main(mainClass.java:24)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Не могу понять почему на моем рабочем компьютере возникает данная ошибка. Правами администратора обладаю, что может быть не так?
Собственно код.
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.pdf.PdfWriter;
import com.itextpdf.tool.xml.XMLWorkerHelper;
/**
* Created by Коренев on 29.12.2015.
*/
public class mainClass {
public static void main(String[] args) throws DocumentException, IOException {
Path path = Paths.get("D:\\hehe.pdf");
File file = Files.createFile(path).toFile();
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
document.open();
XMLWorkerHelper.getInstance().parseXHtml(writer, document,
new URL("http://zakupki.gov.ru/epz/order/notice/printForm/view.html?printFormId=19682025").openStream());
//step 5
document.close();
System.out.println( "PDF Created!" );
}
}
ПЕРЕЙДИТЕ В ПОЛНУЮ ВЕРСИЮ