Remove filename from a URL/Path in java

Consider using org.apache.commons.io.FilenameUtils You can extract the base path, file name, extensions etc with any flavor of file separator: String url = “C:\\windows\\system32\\cmd.exe”; String baseUrl = FilenameUtils.getPath(url); String myFile = FilenameUtils.getBaseName(url) + “.” + FilenameUtils.getExtension(url); System.out.println(baseUrl); System.out.println(myFile); Gives, windows\system32\ cmd.exe With url; String url = “C:/windows/system32/cmd.exe”; It would give; windows/system32/ cmd.exe

Where is Boost.Process?

Boost.Process was accepted for inclusion into Boost on November 9, 2016; and has been included in the 1.64 released on April 19, 2017. Boost.Process is now an official Boost library! It’s documentation is available here: http://www.boost.org/doc/libs/1_64_0/doc/html/process.html For the record, the sources that were reviewed from October 27, 2016 through November 5, 2016 are available on … Read more

Platform independent size_t Format specifiers in c?

Yes: use the z length modifier: size_t size = sizeof(char); printf(“the size is %zu\n”, size); // decimal size_t (“u” for unsigned) printf(“the size is %zx\n”, size); // hex size_t The other length modifiers that are available are hh (for char), h (for short), l (for long), ll (for long long), j (for intmax_t), t (for … Read more

Play a Sound with Python [duplicate]

For Windows, you can use winsound. It’s built in import winsound winsound.PlaySound(‘sound.wav’, winsound.SND_FILENAME) You should be able to use ossaudiodev for linux: from wave import open as waveOpen from ossaudiodev import open as ossOpen s = waveOpen(‘tada.wav’,’rb’) (nc,sw,fr,nf,comptype, compname) = s.getparams( ) dsp = ossOpen(‘/dev/dsp’,’w’) try: from ossaudiodev import AFMT_S16_NE except ImportError: from sys import … Read more

File.separator vs FileSystem.getSeparator() vs System.getProperty(“file.separator”)?

System.getProperties() can be overridden by calls to System.setProperty(String key, String value) or with command line parameters -Dfile.separator=/ File.separator gets the separator for the default filesystem. FileSystems.getDefault() gets you the default filesystem. FileSystem.getSeparator() gets you the separator character for the filesystem. Note that as an instance method you can use this to pass different filesystems to … Read more

Node.js – Find home directory in platform agnostic way

As mentioned in a more recent answer, the preferred way is now simply: const homedir = require(‘os’).homedir(); [Original Answer] Why not use the USERPROFILE environment variable on win32? function getUserHome() { return process.env[(process.platform == ‘win32’) ? ‘USERPROFILE’ : ‘HOME’]; }

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)