How to access resource editor file to Netbeans - java-me

How to access resource editor file to Netbeans?/How resource editor files are imported and opened in Netbeans?Detailed description.

Ok for open the .res file from code, you need to use this lines:
try{
Resources.open("/myResFile.res");
catch(IOException ioe){
//manage the exception
}
The path for your .res file will be different, in my example is like it would be in the src folder.

Related

How do I exclude a folder from the sidebar in Sublime Text permanently, specifying it relative to the open folder?

I've already read this related question (How do I exclude a folder from search in sublime text 3 permanently?) but my question is different since I want to specify only the folder at the open folder's root, not a generic pattern to match at any level in the folder tree.
In Sublime Text 4 I have an open project folder via File --> "Open Folder...".
Let's say my folder layout is this:
mainapp
├── microapp
│ └── node_modules <== don't exclude this (keep it)
├── microapp2
│ └── node_modules <== don't exclude this (keep it)
├── index
├── node_modules <=== exclude this only
├── config
└── assets
I'd like to exclude mainapp/node_modules only, NOT mainapp/microapp/node_modules nor mainapp/microapp2/node_modules. How do I do that?
I'm guessing I need to specify a "folder_exclude_patterns" in the settings.
Side note: why do I need to do this?
Because that folder has so much build content in it (which is constantly-changing as builds occur) that it's actually causing Sublime Text to freeze and lock up and become unusable.
Tested on Linux Ubuntu 18.04.
Through sheer dumb luck and persistence with guessing, I figured it out. // refers to the "open folder root", apparently.
If you want to see this info about // added to the official Sublime Text documentation and default settings file, please upvote my open issue on it here.
Update
I found some official documentation on this: https://www.sublimetext.com/docs/file_patterns.html. The // feature was added as of Sublime Text 4:
If pattern begins with //, it will be compared as a relative path from the project root [added in version 4.0]
My testing, however, proves that the // actually means "path" root, as defined below, however. So, my examples below are still correct.
1. If you have a folder open via File --> "Open Folder...", do this:
Preferences --> Settings --> add this "folder_exclude_patterns" entry to your user settings JSON file:
{
// other user settings here
// exclude only the "mainapp/node_modules" dir
"folder_exclude_patterns": ["//node_modules"],
// other user settings here
}
Again, // means the "open folder's root".
NOTE: Changing your user settings above will apply globally to all of your Sublime Text instances, which may not be what you want. So, it may be better to use a "Project" instead, as described below:
2. If you have the folder open and saved as part of a project, do this:
Project --> Edit Project --> add this "folder_exclude_patterns" entry to your Project settings JSON file:
{
"folders":
[
{
// path to an open folder in a project
"path": "/path/to/mainapp",
// exclude only the "mainapp/node_modules" dir
"folder_exclude_patterns": ["//node_modules"],
}
],
}
You can see in the official project settings file example here (https://www.sublimetext.com/docs/projects.html) that the "folder_exclude_patterns" entry must be at the same level in the JSON settings file as the "path" entry.
I also first learned this from #smhg's comment here. Thank you!
To open another folder in your project, go to Project --> "Add Folder to Project...". Once you have multiple folders open in your project, you'll have to add multiple entries of "folder_exclude_patterns", as desired, like this:
{
"folders":
[
{
// **absolute path** to open a folder in a project
"path": "/path/to/mainapp",
// exclude only the "mainapp/node_modules" dir
"folder_exclude_patterns": ["//node_modules"],
},
{
// or **relative path** to open another folder in the project;
// the path is relative to the location of the
// "project_name.sublime-project" project file itself
"path": "some_dir",
// exclude only the "some_dir/path/to/excluded_folder" dir
"folder_exclude_patterns": ["//path/to/excluded_folder"],
},
],
}
Bonus: How to create a project in Sublime Text:
To create a Project from an open folder, the steps are like this:
Open a folder: File --> "Open Folder..."
Save it as part of a project: Project --> "Save Project As..."
Now you can choose where to save your project_name.sublime-project file. This is the file you are editing when you go to Project --> "Edit Project" above. To open a project go to Project --> "Open Project...".
See also:
Issue I opened: https://github.com/sublimehq/sublime_text/issues/5234
Comment I wrote on the Sublime Text forum: https://forum.sublimetext.com/t/a-way-to-specify-root-in-project-settings/7756/4?u=ercaguy
Official Project settings documentation: https://www.sublimetext.com/docs/projects.html. This includes:
Each object must have a "path" key, which may be relative to the project directory, or a fully qualified path.
How do I exclude a folder from search in sublime text 3 permanently? - answer which explains how to exclude a file or folder from the side bar in Sublime Text, versus excluding a file or folder from search, such as Goto Anything or Find in Files.

java.io.FileNotFoundException: Resource not found: /credentials.json on Java QuickStart for Classroom API

I have implemented the Java QuickStart for the Classroom API and am getting an error message "java.io.FileNotFoundException: Resource not found: /credentials.json" at run-time. I copied my credentials.json file to the Project res directory, but continue to get this error. Any suggestions?
I tried it in a different way than I found on other websites, and it worked for me.
replace below code:
InputStream in = GoogleSheetAPIHandler.class.getClass().getResourceAsStream(CREDENTIALS_FILE_PATH);
With this code:
InputStream in = new FileInputStream(CREDENTIALS_FILE_PATH);
You need to import credential.json file into the src/main/resources folder in eclipse. You may be included in the project folder. But you need to import it into eclipse.
locate your credentials.json file in the folder.
click and drag it
drop it in src/main/resource and click ok.
After importing into eclipse it should show like the below image.
There are two steps needed to find the resource in Eclipse:
To have the file in the resources folder
Create the resource folder (if it does not exist): src/main/resouces
Add the credential file to the resource folder: src/main/resouces/credential.json
To have the resources folder in the Source Java Build Path
Go to Eclipse Path Source: Project > Properties > Java Build Path > Source (tab)
Add resources folder: Add Folder ... (button) > resources (check box) > OK (button)
https://stackoverflow.com/a/46950488/10850340
The name of your file has to be credentials only, if you have credentials.json as the name of your file in your folder you will get this error.

how I can prevent res.sendFile changing file path?

I'm using node.js and want to send file to the frontend. So I specified the direct path to my file like:
path = "c:/app/A"
and when I run res.sendFile(path, fileName);
I'm getting the Error: ENOENT: no such file or directory, stat '/home/projects/c:/app/A'
How I can disable this auto path adding "/home/projects" part?
I want to download file that is not in my project folder with my code. File is in my computer in different folder.
Try to use \\ as path delimiter for Windows (c:\\app\\A) and read about Node.js module "path".
so I need use just new URL(file:${"c:/app/A"});
so it will be like that:
let filename = "someName.com"
let absPath = "c:/app/someName.com";
fs.writeFileSync(`${filename}`, fs.readFileSync(new URL(`file:${absPath}`)));
res.download(`${filename}`, `${filename}`)

How to define a file in Kotlin

I need to use a xml file in my code,
in Java it looks like this:
File inputFile = new File("test.xml"); //Path: C:\Users\...
however, when i try the same in kotlin, it does not work:
val inputFile = File("test.xml")
I always get an "File not found" exception.
I can't find anything on google on how to include files with Kotlin.
val inputStream: InputStream = File("test.xml").inputStream()
val inputString = inputStream.bufferedReader().use { it.readText() }
println(inputString)
Source : kotlination.com
The file must be in the root of your project, the same folder containing your src/ folder.
These should give the exact same results, if you run both with the same working directory. You can check or set the working directory (relative to which file.xml will be looked for) in the Run/Debug configuration.
Since you have Android Studio tag: if you are creating an Android application/library and want the file to be included with it, you should read https://developer.android.com/guide/topics/resources/index.html.

How to get filepath of a file in Azure Service Fabric

I have a project which is in an Azure Service Fabric Solution. How can I get specific full filepath of a content file? The content file is in the same folder with my source code.
What I tried:
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location
But it turns out:
C:\SfDevCluster\Data_App_Node_4\ABCXYZType_App126\ABCXYZPkg.Code.1.0.0\ABCXYZ.dll
This is a file in bin/debug folder
To get the location of content files you can use:
var path = Path.Combine(
FabricRuntime.GetActivationContext().GetCodePackageObject("Code").Path,
"Readme.txt");
ServiceEventSource.Current.ServiceMessage(this.Context, File.ReadAllText(path));
provided that the file Readme.txt has the Build Action is set to "Content" and the Copy to Output Directory setting is set to something else than "do not copy".

Resources