Example usage for java.io File isHidden

List of usage examples for java.io File isHidden

Introduction

In this page you can find the example usage for java.io File isHidden.

Prototype

public boolean isHidden() 

Source Link

Document

Tests whether the file named by this abstract pathname is a hidden file.

Usage

From source file:de.tudarmstadt.ukp.dkpro.core.api.io.ResourceCollectionReaderBase.java

/**
 * Get the URI of the given resource.//  www . j av a  2 s.  c  om
 * 
 * @param aResource
 *            a resource
 * @param aFileOrDir
 *            if true try to return only files, if false try to return only dirs
 * @return the URI of the resource
 */
private URI getUri(org.springframework.core.io.Resource aResource, boolean aFileOrDir) throws IOException {
    try {
        final File file = aResource.getFile();

        // Exclude hidden files/dirs if requested
        if (file.isHidden() && !this.includeHidden) {
            return null;
        }

        // Return only dirs or files...
        if ((aFileOrDir && file.isFile()) || (!aFileOrDir && file.isDirectory())) {
            return aResource.getFile().toURI();
        } else {
            return null;
        }
    } catch (final IOException e) {
        return aResource.getURI();
    } catch (final UnsupportedOperationException e) {
        return aResource.getURI();
    }
}

From source file:com.app.sample.chatting.activity.chat.ChatActivity.java

private void initMessageInputToolBox() {
    box.setOnOperationListener(new OnOperationListener() {
        @Override//www. jav a2  s  . c  o  m
        public void send(String content) {
            try {
                if (chatOfFriend == null) {
                    MyApplication.showToast("");
                    return;
                }

                chatOfFriend.sendMessage(content);

            } catch (SmackException.NotConnectedException e) {
                e.printStackTrace();
                MyApplication.showToast("??");
            }
            NeoChatHistory hzChatHistory = new NeoChatHistory(null, Constant.getMyOpenfireId(), chatwithWho,
                    System.currentTimeMillis(), 1, content, true);
            //Long id, String myJID, String friendJID, Long time, Integer sendState, String body

            MessageChat message = new MessageChat(MessageChat.MSG_TYPE_TEXT, MessageChat.MSG_STATE_SUCCESS,
                    "Tom", "avatar", "Jerry", "avatar", content, true, true,
                    transferLongToDate(hzChatHistory.getTime()));
            datas.add(message);
            adapter.refresh(datas);
            mRealListView.setSelection(adapter.getCount() - 1);
            SaveUtil.saveChatHistoryMessage(hzChatHistory);
            //                createReplayMsg(message);
        }

        @Override
        public void selectedFace(Faceicon content) {
            MessageChat message = new MessageChat(MessageChat.MSG_TYPE_FACE, MessageChat.MSG_STATE_SUCCESS,
                    "Tom", "avatar", "Jerry", "avatar", content.getPath(), true, true, new Date());
            datas.add(message);
            adapter.refresh(datas);
            //                createReplayMsg(message);
        }

        @Override
        public void selectedEmoji(Emojicon emoji) {
            box.getEditTextBox().append(emoji.getValue());
        }

        @Override
        public void selectedBackSpace(Emojicon back) {
            DisplayRules.backspace(box.getEditTextBox());
        }

        @Override
        public void selectedFunction(int index) {
            switch (index) {
            case 0:
                goToAlbum();
                break;
            case 1:
                goToCamera();
                break;
            }
        }
    });

    List<String> faceCagegory = new ArrayList<>();
    //        File faceList = FileUtils.getSaveFolder("chat");
    File faceList = new File("");
    if (faceList.isDirectory()) {
        File[] faceFolderArray = faceList.listFiles();
        for (File folder : faceFolderArray) {
            if (!folder.isHidden()) {
                faceCagegory.add(folder.getAbsolutePath());
            }
        }
    }

    box.setFaceData(faceCagegory);
    mRealListView.setOnTouchListener(getOnTouchListener());
}

From source file:com.ds.avare.utils.FolderPreference.java

/**
 * //from ww w. j  a  v a 2 s. c  o  m
 */
private void loadFileList() {

    /*
     * Checks whether mPath exists
     */
    if (mPath.exists()) {
        FilenameFilter filter = new FilenameFilter() {
            @Override
            public boolean accept(File dir, String filename) {
                File sel = new File(dir, filename);
                /*
                 * Filters based on whether the file is hidden or not, and is a folder
                 */
                return (!sel.isHidden());
            }
        };

        String[] fList = mPath.list(filter);
        if (fList == null) {
            fList = new String[0];
        }
        mFileList = new Item[fList.length];
        for (int i = 0; i < fList.length; i++) {
            mFileList[i] = new Item(fList[i], android.R.drawable.alert_light_frame);

            /*
             * Convert into file mPath
             */
            File sel = new File(mPath, fList[i]);

            /*
             * Set drawables
             */
            if (sel.isDirectory()) {
                if (sel.canWrite()) {
                    mFileList[i].icon = android.R.drawable.ic_menu_save;
                } else {
                    mFileList[i].icon = android.R.drawable.ic_lock_lock;
                }
            }
            /*
             * File is for information only
             */
            else {
                mFileList[i].icon = android.R.drawable.alert_light_frame;
            }
        }

        if (!mFirstLevel) {
            Item temp[] = new Item[mFileList.length + 1];
            for (int i = 0; i < mFileList.length; i++) {
                temp[i + 1] = mFileList[i];
            }
            temp[0] = new Item(mContext.getString(R.string.Up), android.R.drawable.ic_menu_revert);
            mFileList = temp;
        }
    }

    if (mFileList == null) {
        return;
    }
    /*
     * Set the adapter with file list
     */
    mAdapter = new ArrayAdapter<Item>(mContext, android.R.layout.select_dialog_item, android.R.id.text1,
            mFileList) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            /*
             * creates view
             */
            View view = super.getView(position, convertView, parent);
            TextView textView = (TextView) view.findViewById(android.R.id.text1);

            /* 
             * put the image on the text view
             */
            textView.setCompoundDrawablesWithIntrinsicBounds(mFileList[position].icon, 0, 0, 0);

            /*
             *  add margin between image and text (support various screen
             */
            textView.setCompoundDrawablePadding(10);
            textView.setTextColor(Color.parseColor("#FF71BC78"));
            return view;
        }
    };

    /*
     * Show where we are
     */
    mPathView.setText(mPath.getAbsolutePath());
}

From source file:no.digipost.android.gui.content.UploadActivity.java

private void refreshFilesList() {
    absolutePath.setText(mDirectory.getAbsolutePath());

    mFiles.clear();/*from   w  ww  .  j ava  2  s  .co  m*/

    File[] files = mDirectory.listFiles();

    if (files != null && files.length > 0) {
        for (File f : files) {
            if ((f.isHidden() && !mShowHiddenFiles) || !isAcceptedFileExtension(f)) {
                continue;
            }

            mFiles.add(f);
        }

        Collections.sort(mFiles, new FileComparator());
    }
    listAdapter.notifyDataSetChanged();
}

From source file:ng.uavp.ch.ngusbterminal.FileSelectFragment.java

/** Identify all sub-directories and files within a directory. 
 *  @param directory The directory to walk.
 * *//*  ww w  . ja  v a  2 s  . co m*/
private ArrayList<File> getDirectoryContent(File directory) {

    ArrayList<File> displayedContent = new ArrayList<File>();
    File[] files = null;

    if (fileFilter != null) {
        files = directory.listFiles(fileFilter);
    } else {
        files = directory.listFiles();
    }

    // Allow navigation back up the tree when the directory is a sub-directory.
    if (directory.getParent() != null) {
        displayedContent.add(new File(PARENT));
    }

    // Get the content in this directory.
    if (files != null) {
        for (File f : files) {

            boolean canDisplay = true;

            if (selectionMode == Mode.DirectorySelector && !f.isDirectory()) {
                canDisplay = false;
            }

            canDisplay = (canDisplay && !f.isHidden());

            if (canDisplay) {
                displayedContent.add(f);
            }
        }
    }

    return displayedContent;

}

From source file:com.qspin.qtaste.ui.tools.FileNode.java

/**
 * Loads the children, caching the results in the children ivar.
 *//*from w  ww. j  a v a 2  s . co  m*/
public Object[] getChildren() {
    if (children != null) {
        return children;
    }
    if (this.isTestcaseDir()) {
        try {
            ArrayList<TestDataNode> arrayDataNode = new ArrayList<>();
            // load test case data
            File tcDataFile = this.getPythonTestScript().getTestcaseData();
            if (tcDataFile == null) {
                return new Object[] {};
            }
            CSVFile csvDataFile = new CSVFile(tcDataFile);
            List<LinkedHashMap<String, String>> data = csvDataFile.getCSVDataSet();
            Iterator<LinkedHashMap<String, String>> it = data.iterator();
            int rowIndex = 1;
            while (it.hasNext()) {
                LinkedHashMap<String, String> dataRow = it.next();
                if (dataRow.containsKey("COMMENT")) {
                    String comment = dataRow.get("COMMENT");
                    arrayDataNode.add(new TestDataNode(tcDataFile, comment, rowIndex));
                }
                rowIndex++;
            }
            children = arrayDataNode.toArray();
            return children;
        } catch (IOException ex) {
            // unable to read data file

        }

    } else {
        ArrayList<FileNode> arrayFileNode = new ArrayList<>();
        if (f.isDirectory()) {
            File[] childFiles = FileUtilities.listSortedFiles(f);
            for (File childFile : childFiles) {
                FileNode fn = new FileNode(childFile, childFile.getName(), m_TestSuiteDir);
                boolean nodeToAdd = fn.isTestcaseDir();
                if (!fn.isTestcaseDir()) {
                    // go recursilvely to its child and check if it must be added
                    nodeToAdd = checkIfDirectoryContainsTestScriptFile(childFile);
                }
                if (nodeToAdd && !childFile.isHidden()) {

                    arrayFileNode.add(fn);
                }
            }
        }
        children = arrayFileNode.toArray();
    }
    if (children == null) {
        return new Object[] {};
    } else {
        return children;
    }
}

From source file:com.nary.io.FileUtils.java

private static List<Map<String, cfData>> createFileVector(List<File> files, File rootdir, boolean recurse) {
    if (files == null)
        return null;

    String rootDirString = rootdir.getAbsolutePath();
    List<Map<String, cfData>> resultVector = new ArrayList<Map<String, cfData>>();
    int rootprefix = 1 + rootDirString.length();

    for (int i = 0; i < files.size(); i++) {
        File f = files.get(i);
        Map<String, cfData> hm = new FastMap<String, cfData>();

        if (recurse) {
            // Make this a relative path
            hm.put("name", new cfStringData(f.getAbsolutePath().substring(rootprefix)));
            hm.put("directory", new cfStringData(rootDirString));
        } else {//from  www  .j  a v a2 s.c o  m
            hm.put("name", new cfStringData(f.getName()));
            hm.put("directory", new cfStringData(f.getParent()));
        }

        hm.put("size", new cfNumberData(f.length()));

        if (f.isDirectory()) {
            hm.put("type", new cfStringData("Dir"));
        } else {
            hm.put("type", new cfStringData("File"));
        }

        hm.put("datelastmodified", new cfDateData(f.lastModified()));

        StringBuilder attrs = new StringBuilder();

        if (!f.canWrite())
            attrs.append('R');

        if (f.isHidden())
            attrs.append('H');

        hm.put("attributes", new cfStringData(attrs.toString()));
        hm.put("mode", new cfStringData(""));

        resultVector.add(hm);
    }

    return resultVector;
}

From source file:org.sonar.server.startup.GwtPublisherTest.java

@Test
public void shouldCleanTheOutputDirOnStop() throws IOException {
    File dir = new File(
            "./target/test-tmp/org/sonar/server/startup/GwtPublisherTest/shouldCleanTheOutputDirOnStop");
    if (!dir.exists()) {
        FileUtils.forceMkdir(dir);/*from w ww  .  ja  v a2s. com*/
    }
    File file = new File(dir, "test.txt");
    FileUtils.writeStringToFile(file, "test");
    File testDir = new File(dir, "testDir");
    testDir.mkdir();
    File testDirFile = new File(testDir, "test.txt");
    FileUtils.writeStringToFile(testDirFile, "test");

    File scm = new File(dir, ".svn");
    scm.mkdir();

    assertThat(file.exists(), is(true));
    assertThat(testDir.exists(), is(true));
    assertThat(testDirFile.exists(), is(true));
    assertThat(scm.exists(), is(true));

    GwtPublisher publisher = new GwtPublisher(null, dir);
    publisher.cleanDirectory();
    assertThat(dir.exists(), is(true));
    assertThat(FileUtils.listFiles(dir, null, true).size(), is(0));
    scm = new File(dir, ".svn");
    // won't be hidden under windows and test will fail, no hidden setter on file unfortunatly
    if (scm.isHidden()) {
        assertThat(scm.exists(), is(true));
    }
}

From source file:jackpal.androidterm.TermPreferences.java

private ListPreference setFontList(ListPreference fontFileList) {
    File files[] = new File(FONTPATH).listFiles();
    ArrayList<File> fonts = new ArrayList<File>();

    if (files != null) {
        for (File file : files) {
            if (file.isFile() == true && file.getName().matches(".*\\.(?i)(ttf|ttc|otf)")
                    && file.isHidden() == false) {
                fonts.add(file);//from w w  w  . j a  v a 2s. c om
            }
        }
    }
    Collections.sort(fonts);
    int i = fonts.size() + 1;
    CharSequence[] items = new CharSequence[i];
    CharSequence[] values = new CharSequence[i];

    i = 0;
    Resources res = getResources();
    String systemFontName = res.getString(R.string.entry_fontfile_default);
    items[i] = systemFontName;
    values[i] = systemFontName;
    i++;

    Iterator<File> itr = fonts.iterator();
    while (itr.hasNext()) {
        File file = itr.next();
        items[i] = file.getName();
        values[i] = file.getName();
        i++;
    }

    fontFileList.setEntries(items);
    fontFileList.setEntryValues(values);
    return fontFileList;
}

From source file:com.enjoyxstudy.selenium.htmlsuite.MultiHTMLSuiteRunner.java

/**
 * @param testCaseDir/*from  w ww  . j  a va2s  . c  o m*/
 * @return suiteFile
 * @throws IOException
 */
private File[] generateHTMLSutes(File testCaseDir) throws IOException {

    File suiteFile = null;
    if (!testCaseDir.isDirectory()) {
        suiteFile = testCaseDir;
        testCaseDir = testCaseDir.getParentFile();
    }

    if (!testCaseDir.exists()) {
        throw new IOException("Can't find Test Case dir:" + testCaseDir.getAbsolutePath());
    }

    ArrayList<File> testSuiteList = new ArrayList<File>();

    File[] testCaseFiles = collectTestCaseFiles(testCaseDir);
    if (testCaseFiles.length != 0) {

        if (suiteFile == null) {
            suiteFile = new File(testCaseDir, "generatedTestSuite.html");
        }
        generateHTMLSute(suiteFile, testCaseFiles, null);
        testSuiteList.add(suiteFile);

    } else {

        File[] childDirs = testCaseDir.listFiles(new FileFilter() {
            public boolean accept(File pathname) {
                return pathname.isDirectory() && !pathname.isHidden();
            }
        });
        Arrays.sort(childDirs);

        for (File childDir : childDirs) {
            File childSuiteFile = new File(testCaseDir, childDir.getName() + ".html");
            generateHTMLSute(childSuiteFile, collectTestCaseFiles(childDir),
                    childDir.getName() + PATH_SEPARATOR);
            testSuiteList.add(childSuiteFile);
        }
    }

    log.info("Generate HTMLSuites total count[" + testSuiteList.size() + "]");

    return testSuiteList.toArray(new File[testSuiteList.size()]);
}