how to open a text file(or any file) located in a folder other than the project folder in java
Date : March 29 2020, 07:55 AM
will help you From the doc's for java.io.File: String selectedFile=fc.getFile();
String selectedDirectory=getDirectory();
File file = new File(selectedDirectory, selectedFile);
|
How to read json file located in project folder in iPhone PhoneGap using Javascript
Date : March 29 2020, 07:55 AM
wish helps you You would read it just like it is on your server. Solution 1 - jQuery //Load categories object JSON
jQuery.getJSON("categories.json", function(data){
// data is yours parsed object
});
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"/>
<script src="http://www.fajrunt.org/js/jquery-1.9.1.min.js"></script>
<title>Read JSON Demo</title>
<script>
jQuery.getJSON("categories.json", function(data){
alert(data.balance);
});
</script>
</head>
<body>
Read JSON Demo
</body>
</html>
{"balance":1000.21,"num":100,"nickname":null,"is_vip":true,"name":"foo"}
var xmlhttp;
var jsonObject;
// code for IE7+, Firefox, Chrome, Opera, Safari
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
// code for IE6, IE5
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
jsonObject = JSON.parse(xmlhttp.responseText);
alert(jsonObject.balance);
}
}
xmlhttp.open("GET","categories.json",true);
xmlhttp.send();
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"/>
<title>Read JSON Demo</title>
<script>
var xmlhttp;
var jsonObject;
// code for IE7+, Firefox, Chrome, Opera, Safari
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
// code for IE6, IE5
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
jsonObject = JSON.parse(xmlhttp.responseText);
alert(jsonObject.balance);
}
}
xmlhttp.open("GET","categories.json",true);
xmlhttp.send();
</script>
</head>
<body>
Read JSON Demo
</body>
</html>
{"balance":1000.21,"num":100,"nickname":null,"is_vip":true,"name":"foo"}
|
Why does not process a $.getJSON function if file located not in project folder?
Tag : jquery , By : Shrek Qian
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Due to the Same-Origin Policy, you cannot use AJAX to read a file from a different domain. The whole point of $.getJSON() is that it uses JSONP to bypass this restriction.
|
How to read a file that is located in the project folder java
Date : November 09 2020, 11:01 PM
To fix this issue Looking at the error it doesn't look like you are getting the full path. Instead of p.concat("/HackGSU/bad_words.txt");
p = p.concat("/HackGSU/bad_words.txt");
|
java, loading of resources fails: unable to resolve file:/my-jar.jar!/folder/my-file
Tag : java , By : leorick
Date : March 29 2020, 07:55 AM
|