How to Open .rd file extension in Java - java

Can anyone help me in figuring out how to retreive data from .rd extension files in java. I want to copy data from .rd extension file into a word document file. I am new to java and hence unable to sort out the problem.
Thanks in Advance
Sai

See these documents :
Guidelines for Rd files : http://developer.r-project.org/Rds.html
Parsing Rd File : http://developer.r-project.org/parseRd.pdf
Once you are able to read the file by previous methods, you can convert into word document by using Apache POI.
Hope This Helps!

Related

FileNotFound while File is there

I am using getClassLoader().getResources to find the path for Jsoup to parse.
String path = JsoupDemo1.class.getClassLoader().getResource("student.xml").getPath();
Document document = Jsoup.parse(new File(path), "utf-8");
Elements names = document.getElementsByTag("name");
System.out.println(names.size());
My student.xml has been placed under the src folder in my module "day11_xml" and this code snippet comes from the class JsoupDemo1 in the package cn.itcast.xml.jsoup under the same module of "day11_xml". The error messages reads as follows:
java.io.FileNotFoundException:/Users/dingshun/Downloads/New%20Java%20Projects/demo/out/production/day11_xml/student.xml (No such file or directory)
I don't get it, as I can find the exact file in the given path. I'm confused, but could you guys help me out? Also, I'm new to both Java programming and this forum and if this question sounds silly or my question format is not right, please let me know.
What you're doing looks good. Maybe use the stream version JSoup.parse.
URL url = JsoupDemo1.class.getClassLoader().getResource("student.xml");
InputStream stream = JsoupDemo1.class.getClassLoader().getResourceAsStream("student.xml");
document = Jsoup.parse(stream, "utf-8", url.toURI()toString());
The documentation linked seems to imply it will work with html not xml, so maybe you need to use the other argument which provides a parser?
Actually, it turned out that Jsoup could not find my file because the path name "New%20Java%20Projects" has spaces between them. When I reload the file in a folder which has no spaces in its name, it works out just fine. So it can parse xml using parse​(File in, String charsetName) method. It seems it cannot parse path name which has spaces in it.

Getting MIME type of a File

I want to get mimetype of a file can anyone please help me
I want MIME Type like this...
File file=new File("example.jpeg");
String MimeTypeOfFile=/*files mimetype*/;
Thank You in Advance
You can use the Apache Tika Library: It detects and extracts metadata and text from over a thousand different file types
http://tika.apache.org/0.7/detection.html
It has various methods like extension checking or reading file data to detect mime-type. It would be easy and efficient rather than writing yourself.
Example :
System.out.println(new Tika().detect(new File(PATH_TO_FILE)));

Pivot table refresh and save code in aspose cells for java corrupts excel file

I am using aspose-cells-8.7.2-java. When I refresh the pivot table and save it, the excel file is getting corrupted. When I try to open the excel file I am getting the alert message as below :
"Excel found unreadable content in 'Book1.xlsx'.Do you want to recover the contents of this workbook?If you trust the source file of this workbook, click yes."
The code is as below :
Workbook wb = new Workbook("Book1.xlsx");
PivotTable pt = wb.getWorksheets().get(1).getPivotTables().get(0);
pt.refreshData();
pt.calculateData();
wb.save("Book1.xlsx");
Any help ?
I found this thread where the same issue is logged as a ticket :
http://www.aspose.com/community/forums/thread/683715/aspose.cells-generates-a-corrupted-xlsx-file-excel-2007-fails-to-open.aspx.
Is this issue solved?
I'm afraid the logged issue is not resolved yet. By the way, do you use similar Excel file or yours template file "Book1.xlsx" is different. Moreover, your issue can be template specific (if you are using different file) and might have different scenarios, so we need your template "Book1.xlsx" file to properly evaluate your issue on our end. We recommend you to kindly create a separate thread in Aspose.Cells forum with your template Excel file, we will evaluate your issue and help you better there.
I am working as Support developer/ Evangelist at Aspose.

Java/XML: Read XML to vector in java

I have XML file with a lot of records in XML.
for example,
<ChinRecord>
<p>(..)(..)(..)(..)(..)(......)</p>
<CP>
<p>(..)(..)(..)(..)(..)(......)</p>
</CP>
<origin>30Ntr431_C.TXT</origin>
<What>t</What>
<TZ>q84393</TZ>
<wQ>WQ</wQ>
<time>2009-11-4</time>
</ChinRecord>
<ChinRecord>
<p>(..)(..)(..)(..)(..)(......)</p>
<CP>
<p>(..)(..)(..)(..)(..)(......)</p>
</CP>
<origin>30Ntr431_C.TXT</origin>
<What>true</What>
<TZ>7027AEC</TZ>
<wQ>WQ</wQ>
<time>2009-11-30</time>
</ChinRecord>
I use the next line:
Chin newRecord = (Chin)xstream.fromXML(xml);
(I have datatype of Chin)
and It's really give me the first record of the xml in newRecord . But What I do when I want to save all the records? I create new Vector, but how I acsses all the records in the file?
Thanks.
Maybe you can use the ObjectInputStream of XStream as described here: http://x-stream.github.io/objectstream.html
But this would require to wrap your ChinRecordelements into some XML root:
<object-stream>
<ChinRecord>
..
</ChinRecord>
<ChinRecord>
..
</ChinRecord>
..
</object-stream>

Android get 1st result and copy from google search(automatic)

I want a code to search to google engine for songs via zippyshare . For example the keyword will be "inna sun is up zippyshare" and the first result is this url www32.zippyshare.com/v/55151563/file.html . i want to retrieve the code 55151563 from the the 1st result of google.
Thank you in advance
I will not write the code for you, but I can tip you to the right approach.
Get the url using String search = "http://www.google.com/search?hl=en&q=" + string_to_search;
Download the webpage using URL, InputStream and OutputStream. Check this post here.
Read the file and find the first instance of zippyshare.
Here you can read about xml parsing

Categories

Resources