filenames

How can i share apk file in my app (send app itself)

被刻印的时光 ゝ 提交于 2019-12-05 01:14:39
问题 I am trying to use this code to send my application apk file to another device: public static void sendAppItself(Activity paramActivity) throws IOException { PackageManager pm = paramActivity.getPackageManager(); ApplicationInfo appInfo; try { appInfo = pm.getApplicationInfo(paramActivity.getPackageName(), PackageManager.GET_META_DATA); Intent sendBt = new Intent(Intent.ACTION_SEND); sendBt.setType("*/*"); sendBt.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + appInfo.publicSourceDir));

What should I name my files with generic class definitions?

淺唱寂寞╮ 提交于 2019-12-05 01:14:05
I'm writing a couple of classes that all have generic type arguments, but I need to overload the classes because I need a different number of arguments in different scenarios. Basically, I have public class MyGenericClass<T> { ... } public class MyGenericClass<T, K> { ... } public class MyGenericClass<T, K, L> { ... } // it could go on forever, but it won't... I want them all in the same namespace, but in one source file per class. What should I name the files? Is there a best practice? I've seen people use MyGenericClass`1, MyGenericClass`2 or MyGenericClass`3 (the number is the number of

Move a group of files to a new folder if their file names, minus extension, matches?

僤鯓⒐⒋嵵緔 提交于 2019-12-04 21:22:41
I have a folder full of files that have the same name but different file extensions. For example: file-1.ai file-1.svg file-1.pdf file-2.ai file-2.svg file-2.txt file-3.ai file-3.svg example-1.pdf example-3.mov Is there any way in Linux (any programming language will do) I can move the group of files to a new folder (either a new folder per file group or all in one folder) if their file names, minus extension, matches? Think you want something like this. #!/bin/bash dir="/somedir/" for i in "$dir"*; do if [ -f "$i" ]; then filename="${i%%.*}" if [ ! -d "$filename" ]; then mkdir "$filename" fi

Filename from URL not containing filename suffix

风流意气都作罢 提交于 2019-12-04 20:15:19
I need to download a file from a URL except I don't know what type the file will be and the URL I am using doesn't have /random.file at the end of it so I can't parse the url for the filename. At the moment I'm using the Android download manager which works greats and means I don't have handle the download but I can't see anyway to get the file name out of the file its downloading. If I load the same url in Firefox for example it asks 'Download file: Nameoffile.extension'. Is there a way for me to replicate this behaviour and get the file name before I download the file? You are better off

How do I write some (bash) shell script to convert all matching filenames in directory to command-line options?

梦想的初衷 提交于 2019-12-04 20:11:18
Apparently the answer to my question "Can I restrict nose coverage output to directory (rather than package)?" is no, but I can pass a --coverage-package=PACKAGE option to nose with the package name of each .py file in the directory. So for example, if the directory contains: foo.py bar.py baz.py ...then I would need to use the command: nosetests --with-coverage --coverage-package=foo --coverage-package=bar --coverage-package=baz So my question is, can someone write some shell script code (preferably sh or bash) to take all the filenames in the current directory with a .py extension and

SPLFileInfo: get filename without extension

有些话、适合烂在心里 提交于 2019-12-04 17:54:50
问题 I'm accessing a number of files in the SPLFileInfo object. I see a way to get the path, filename, and even extension of the file. Is there a way to get the filename without extension? Here's the code I've been working with but I'm hoping to get something more elegant. Is there an out of the box solution? $file = new SplFileInfo("path/to/file.txt.zip"); echo 'basename: '.$file->getBasename(); echo PHP_EOL; echo 'filename: '.$file->getFilename(); echo PHP_EOL; echo 'extension: '.$file-

Automated renaming of linux filenames to a new filenames that are legal in windows

吃可爱长大的小学妹 提交于 2019-12-04 13:43:24
I would like to rename a linux file to a filename that is legal in windows. It should not be longer than is allowed and should not have characters that are not allowed in windows. Sometimes I copy the title from papers to a filename and they have special characters such as – , ® , or ? Also there is there are some kind of characters sometimes at the ends of lines generated when copying and pasting a title from a pdf. You can see them when using sed -n 'l': echo 'Estrogen receptor agonists and estrogen attenuate TNF-α induced α apoptosis in VSC4.1 motoneurons.pdf' | sed -n 'l' Estrogen receptor

Validate Windows filename

淺唱寂寞╮ 提交于 2019-12-04 12:05:59
How do I determine whether a given string is a valid Windows filename? I'm thinking of some function that I can give a string and that returns a boolean. It should check for disallowed characters (<>:"/\|?*) and for reserved words (CON, PRN, et cetera). isValidWindowsFilename('readme.txt'); // true isValidWindowsFilename('foo/bar'); // false isValidWindowsFilename('CON'); // false I've found a MSDN reference describing exactly what is valid: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx I've also found the same question for Java, with an answer that does what I

Why the names of some css, js files have random numbers in them?

被刻印的时光 ゝ 提交于 2019-12-04 12:04:28
Some websites seem to have file names such as 'assets/app-02b4523sev8fsd56e.js'. I have noticed that these numbers do not change though, so I thought it has something to do with security but I am not sure. Is there any reason behind this? Remote This is normally to break caches stored by the browser so that the latest version of a file is loaded. Every time a file is changed this value will normally be changed also. This can be done manually by changing the filename and/or the paths in other files referencing this file, or this can be done programatically in some way. You may also see this

Reading accented filenames in R using list.files

浪尽此生 提交于 2019-12-04 09:39:42
I am reading county geojson files provided here into R Studio (R 3.1, Windows 8) for each of the states. I am using list.files() function in R. For state PR, which has many counties with accented (Spanish) names viz. Bayamón.geo.json, Añasco.geo.json. The function list.files() returns shortened form of file names like An~asco.geo.json, Bayamo´n.geo.json. And when in the next step I try to read the actual file using above filenames. I get an error that these files don't exist. I was using system default encoding ISO-8859-1 and also tried changing it to UTF-8, but no luck. Please help me solve