I have an app. Which is in RC state. I've started finalizing works by splitting the classes to separate files with appropriate import sets at another location but suddenly I've found that cleaner version cannot read from any folder. So I investigated that if I compile the code in another location except the actual (original) app cannot read from any folder.
Strange is that from folders from those cannot be read can be obtained path (subdirectories included).
I have packed this app to executable jar file before started this works. Maybe somewhere in JVM is something stuck?
Note: New files are compiled without error. I've tried both original source and new sources.
Failure is in methods File.list() or File.listFiles(). The same using directory stream.
Used packages:
import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableModel;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.io.LineNumberReader;
import java.io.FileReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.DataInputStream;
import java.io.FilenameFilter;
import java.io.FileNotFoundException;
import java.io.IOException;
import javax.swing.UnsupportedLookAndFeelException;
For sure at this part:
private void loadFiles(){
cesta=folderPicker.getSelectedFile();
if(folder==null||loadedCesta!=cesta||(cesta==folderPicker.getSelectedFile()&vetsiPismoVisible==true)){
folder=new File(cesta.getName());
String datFiles[]=folder.list(new FilenameFilter() {
public boolean accept(File folder, String fileName) {
return fileName.endsWith(".dat");}});
If I try:
folder.canRead()
on every folder on my PC and also e.g.on my workstation these new compilations get false as a result. Variable:
folderPicker
is reffering to JFileChooser that is limited to folders and folders are obtained via actionListener of special JButton (not classic Open and Cancel). You can try it from Karolina_RC.jar from link provided in commentary under conditions said.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…