filenames

Reading the java files from the folder

痞子三分冷 提交于 2019-12-02 17:10:47
问题 I have developed an application that reads files from the folder chosen by the user. It displays how many lines of code are in each file. I want only Java files to be shown in the file-chooser (files having .java extension). Below is my code: public static void main(String[] args) throws FileNotFoundException { JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File("C:" + File.separator)); chooser.setDialogTitle("FILES ALONG WITH LINE NUMBERS"); chooser

Can ack find files based on filename only?

為{幸葍}努か 提交于 2019-12-02 17:09:33
Using ack (sometimes packaged as ack-grep) I know that I can find paths that contain a specific string by doing: ack -g somestring But what if I only want files which have "somestring" in their filenames ? You can use find utility. Something like this: find /path/to/look/in -name '*somestring*' -print On some systems, if you omit the path, current directory is used. On other systems you can't omit it, just use . for current directory instead. Also, read man find for many other options. I agree find is the way to go, but you could also easily do it with ack: ack -f | ack "string" Here, "ack -f"

getting corresponding filename of image once button pressed

余生颓废 提交于 2019-12-02 16:43:24
问题 A Set of imagefiles are added to an arraylist(filelist2) of type File.Then an imageview and a button are addded to a vbox,such vboxes are added to a grids of a gripane using a for loop.( number of iterations is equal to size of the filelist2)Once a button is pressed I need to get the corresponding filename of the image within that vbox. Say I pressed the button contained at (1,1) {i.e row no01 ,col no1} I need to get filename of image at (1,1) here's a screenshot: here's my code:

Linux - Replacing spaces in the file names

断了今生、忘了曾经 提交于 2019-12-02 13:53:06
I have a number of files in a folder, and I want to replace every space character in all file names with underscores. How can I achieve this? neesh This should do it: for file in *; do mv "$file" `echo $file | tr ' ' '_'` ; done I prefer to use the command 'rename', which takes Perl-style regexes: rename "s/ /_/g" * You can do a dry run with the -n flag: rename -n "s/ /_/g" * Use sh... for i in *' '*; do mv "$i" `echo $i | sed -e 's/ /_/g'`; done If you want to try this out before pulling the trigger just change mv to echo mv . What if you want to apply the replace task recursively ? How would

File name? Path name? Base name? Naming standard for pieces of a path

◇◆丶佛笑我妖孽 提交于 2019-12-02 13:46:35
I keep getting myself in knots when I am manipulating paths and file names, because I don't have a common naming system that I use. I need to come up with a naming standard and stick to it, and I would like to be clear and consistent with others, so I am opening up to learn the canonical answers. Consider this toy problem: (Windows example, but hopefully answer should be platform independent) You have been given the full name of a folder: C:\users\OddThinking\Documents\My Source. You want to walk the folders underneath, and compile all the .src to .obj. At some point you are looking at the

Reading the java files from the folder

三世轮回 提交于 2019-12-02 08:06:22
I have developed an application that reads files from the folder chosen by the user. It displays how many lines of code are in each file. I want only Java files to be shown in the file-chooser (files having .java extension). Below is my code: public static void main(String[] args) throws FileNotFoundException { JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File("C:" + File.separator)); chooser.setDialogTitle("FILES ALONG WITH LINE NUMBERS"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setAcceptAllFileFilterUsed(false); if (chooser

Reading filename in multiple OS without encoding problem with Ruby

佐手、 提交于 2019-12-02 05:09:00
问题 I want to get all filenames in UTF-8. For example, after I read filename in Windows, I do filename = Iconv.iconv("UTF-8", "Windows-1251", filename) In Ubuntu I don't convert filename and get it in UTF-8. Maybe exists some method to determine OS filename encoding? 回答1: I do this on Ruby 1.9 when I want to make sure things are in UTF-8: if filename.encoding.to_s != 'UTF-8' filename.encode!('UTF-8') end Unless your OS gives a file name encoded with a coding system which doesn't support some

How do I use a variable containing a filename with spaces in a bash script?

≯℡__Kan透↙ 提交于 2019-12-02 04:43:06
问题 I have a simple bash script running on OS X that removes specific files and directories and copies new ones in their place. One Mac .app directory contains a space, and when I run the script there is a "No such file or directory" error. Here is the relevant code. A good amount has been cut out, so simply hard coding these differently isn't possible (the variables must be broken up as they are): CP="cp -Rf" INSTALL_DIR="/Applications/" APP="The App.app" NEWAPP="$HOME/Downloads/The App.app" $CP

Pure ASP upload with utf-8 filenames

我的未来我决定 提交于 2019-12-02 02:29:17
问题 I'm have made a upload page in classic asp and it works fine, as long as the filenames are not in utf-8 characters. I have added charset til the page and the form accepts utf-8 characters but my files are saved as Доклад Региона.pdf bug should be Доклад Региона.pdf I don't know if there is anything more I can do or it is the "Pure-ASP file upload" that does not support utf-8 characters. Does anyone how to fix it? My asp page looks like this <% Response.CodePage = 65001 Response

How was a URL like http://stackoverflow.com/posts/1807421/edit created in PHP?

荒凉一梦 提交于 2019-12-02 02:14:20
When you edit a question on stackoverflow.com, you will be redirected to a URL like this: https://stackoverflow.com/posts/1807421/edit But usually, it should be https://stackoverflow.com/posts/1807491/edit.php or https://stackoverflow.com/posts/edit.php?id=1807491 How was https://stackoverflow.com/posts/1807421/edit created? I know that Stackoverflow.com was not created by using PHP, but I am wondering how to achieve this in PHP? With apache and PHP, you might perform one of your examples using a mod_rewrite rule in your apache config as follows: RewriteEngine On RewriteRule ^/posts/(\d+)/edit