This question already has answers here:
Write/store dataframe in text file
(5 answers)
Closed 4 years ago.
Im new here so i hope to help you and be helped if could be possible.
I made a Apache Spark project using Spark SQL and ML Spark in Java. I've finished this project but i have some problems with the output.
I've got a Dataset<Row> final (final is the name of the dataset) with some information. When i use show() with this dataset ( finals.show(); ) I get the next information:
[2018026,1,9.93,127.66,5.16,245.8,4.426875,6.91]
[2018026,1,9.97,127.89,5.36,244.8,4.426875,6.91]
[2018026,1,6.76,113.54,6.42,228.8,4.426875,6.91]
[2018026,1,6.92,114.2,6.81,224.0,4.426875,6.91]
[2018026,1,6.86,113.98,6.65,226.0,4.426875,6.91]
[2018026,1,6.81,113.76,6.58,227.4,4.426875,6.91]
[2018026,1,6.97,113.49,6.58,225.8,4.426875,6.91]
[2018026,1,6.97,114.42,6.67,221.6,4.426875,6.91]
(The "," is the separator between the fields).
Well, I'm trying to get this output in text file, for example projectSpark.txt but is impossible to me. How can I get this info on a text file?
Should I iterate over the Dataset<Row> or are there some methods to do this?
Thank so much guys.
Regards.
In Java, you can do something like it:
finals.javaRDD().map(x -> x.toString()).saveAsTextFile("your/path");
It will save your dataset in a single text file.
This question already has an answer here:
How do you actually parse values in YAML in Java? [duplicate]
(1 answer)
Closed 6 years ago.
I want to write java program to read set of data from YAML file in cloud foundry.
#Define CDN domains
---
domains:
name : CDN1
quality : 200..300
cost : low
location: http://
name: CDN2
quality: 400..500
cost: high
location: http://
Then, in the program based on the name and quality it should redirect the first request to new location.
Can anyone help me for this?
I`m entirely new in YAML!
Based on my search, I can use snacked YAML or bean YAML, but I don't know what difference is.
You can use Jackson to read YAML, which is widely supported in Spring: https://github.com/FasterXML/jackson-dataformat-yaml
This question already has answers here:
Reading text file always returns 0 - Java
(2 answers)
Closed 7 years ago.
I have a game client jar that has an updater. Its client.jar and it downloads a cache which has all the game files. There is no need to update the client.jar just the cache, but the problem is the version number is hardcoded into the client.
What I've been trying to do ALL day is change the way the version number is obtained, and I just can't get it.
http://pastebin.com/Z5urTUVw
Line 31 is the version number, I need that to read a version number from a dropbox link. Found here - https://dl.dropboxusercontent.com/u/87363031/version.txt
Just 1 simple number, I've been trying to do this for the better part of 6 hours now and I'm bout to lose my cool. Can someone please help me with this?
If you can use Apache Commons IO, there's a very simple way to achieve this using IOUtils:
InputStream in = new URL("https://dl.dropboxusercontent.com/u/87363031/version.txt").openStream();
try {
String version = IOUtils.toString(in));
System.out.println(version);
} finally {
IOUtils.closeQuietly(in);
}
I need to check if any of the 4 uploaded files are same, this check might be on the JSP or Java-Servlet side.
I've been using
var FileName1 = document.getElementById('fileChooser1').value;
var FileName2 = document.getElementById('fileChooser2').value;
if(FileName1 == FileName2)
{
alert("same files cannot be uploaded");
}
But, the problem is that this only deals with the name of the file and this fails if files with same content but different names are uploaded.
So, on apache commons search I found that there is a Default Comparator but I have no idea of how I can use this or is there any other better/simpler way to check for same files.
How can I use the Default Comparator and on what basis does it compare?
Is there any better/simpler solution to this problem in java or javascript?
You can use FileUtils.contentEquals method to compare content of 2 files.
Example
System.out.println(FileUtils.contentEquals(file1, file2));
This question already has answers here:
How do I preserve the existing query string in a mod_rewrite rule
(2 answers)
Closed 8 years ago.
We are trying to redirect bin-ends2 to wines.jsp with a number of parameters passed over to the application server. Apache is stripping the parameters off and so the application server fdoes not know what yo put in the page. The Apache config is:
RewriteRule ^/wines/bin-ends2$ http://qa2:7025/wines/wines.jsp?Form=WinesSearch&type=binends [PT]
Does anyone know how to make this work?
You need to add QSA flag to your rule when you introduce new query string parameters and would like to preserve (better say, include) existing query string.
Your rule should be
RewriteRule ^/wines/bin-ends2$ http://qa2:7025/wines/wines.jsp?Form=WinesSearch&type=binends [QSA,PT]
Useful link: http://httpd.apache.org/docs/current/rewrite/flags.html#flag_qsa