FAQ Database Discussion Community


Static method file path [duplicate]

java,static,absolute-path
This question already has an answer here: Different ways of loading a file as an InputStream 4 answers How do i get the Path of a file in the same package as the class? This doesn't work. public static void SaveAllMockData() throws Exception { InputStream inputStream = getClass().getClassLoader().getResourceAsStream("mockdata.json"); }...

How to find relative path given two absolute paths?

c,path,relative-path,absolute-path
Given two absolute paths, e.g. /a/path/to/a /a/path/to/somewhere/else How can I get a relative path from one to the other, ../a? In a sense, the opposite of what realpath does....

tcsh check if file exists in a given path

user-input,absolute-path,tcsh
First of all, I am new to tcsh and I realize its disadvantages and why it is harmful (and I agree!). However, I don't have a choice and I am needing to write a tcsh script where the user provides a directory as input and the script will check if...

Get absolute path to File

java,absolute-path
So I'm trying to use BufferedImages necause their eaier for and it seems loading them is a bit more finiky. I think you need the absolute path to load them and I have tried just doing src/Package.image.png but when I export to runnable jar it doesn't work. This code works...

How to use a relative path instead of an absolute path in processing?

java,path,processing,relative-path,absolute-path
I am fairly new to processing (and programming in general). In a project that I'm doing I need to access the following path: f = new File("C:/Users/Matthew/ColourFeature/data/image1.jpg"); This, being an absolute path, works without any problem. However since this program will be run on different machines I am trying to...

Converting a File:///… string to an Absolute URI

java,android,uri,filepath,absolute-path
So I am making an app that lets users pick images from their gallery to display, as well as take photos from the camera. The image is previewed via a bitmap that takes the string of the file path. When the user takes a photo the code below handles it...