Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I am currently trying to write an application which allows me to get the code of an image just like when you open an image in a text editor.
I thought about changing the extension of the file and setting up a bufferedreader?
I have no idea how to accomplish this. The best would be having the code from the image in a String or an array.
Any ideas?
Thanks in advance.
I don't know exactly what you mean by "code", but I suggest you use any kind of image library. Maybe this can help you. In the library you can then call methods such as getSize() and more.
EDIT: Is this the code you are looking for?
<x:xmpmeta xmlns:x="adobe:ns:meta/"><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description rdf:about="uuid:faf5bdd5-ba3d-11da-ad31-d33d75182f1b" xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:creator><rdf:Seq xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:li>Corbis</rdf:li></rdf:Seq>
</dc:creator><dc:rights><rdf:Alt xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:li xml:lang="x-default">© Corbis. All Rights Reserved.</rdf:li></rdf:Alt>
</dc:rights></rdf:Description><rdf:Description rdf:about="uuid:faf5bdd5-ba3d-11da-ad31-d33d75182f1b" xmlns:tiff="http://ns.adobe.com/tiff/1.0/"><tiff:artist>Corbis</tiff:artist></rdf:Description><rdf:Description xmlns:xmp="http://ns.adobe.com/xap/1.0/"><xmp:Rating>3</xmp:Rating><xmp:CreateDate>2008-03-14T13:59:26.540</xmp:CreateDate></rdf:Description><rdf:Description xmlns:MicrosoftPhoto="http://ns.microsoft.com/photo/1.0/"><MicrosoftPhoto:Rating>50</MicrosoftPhoto:Rating></rdf:Description></rdf:RDF></x:xmpmeta>
Try regex and read the file as you suggested. Otherwise a JaxB parser might help if you manage to set it up right.
Text-Files != Binary-Files
First line from BufferedReader-Docu sais: "reads text ..."
Ok, we know images are not text. So you need to use any InputStream, so you have a File, you need the FileInputStream. Be warned: If you print those binary-data to console, it is automatically converted into text, some special binary-data may be skipped. You can not paste it into notepad and save the output as image again.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a web app that I am changing to use xPressions from EMC2. There is a point where xPressions returns a pdf document inside a java servlet. Before we added xPressions, we would combine several of these pdfs into one large pdf and send it back to the user/screen. But xPressions can only process one pdf at a time. It is returning the pdf as a byte[] array. So I am trying to find a way to take the byte[] arrays and combine them into one large pdf to send back to the user/screen. Before we had xPressions we were using an old version of Big Faceless (bfo.com) to combine the individual pdfs into one pdf in the servlet. I have not been able to get the byte[] array to a valid pdf using the old bfo.com software. I have searched on Google and here on stack overflow for another technique. I have found answers that are close but most are using Linux or c#. Also, these pdfs are created inside the java servlet and are not existing on a hard drive where I could read them in and convert them. I have to take the byte[] array and work with that. So, does anyone have any ideas for me ? Thanks in advance !
You can use PDFBox for merging your pdf files. PDFMergerUtility class has a method addSource which takes in an inputstream, you can convert the byte array to inputstream and add that as a source.
PDFMergerUtility merger = new PDFMergerUtility();
merger.addSource(...);
merger.addSource(...);
merger.setDestinationFileName(...);
merger.mergeDocuments();
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I want to write my own desktop keyboard, that can be used to work with some programs like excel. I've already written all graphical stuff, but i can't find any information about redirecting program output to another program. I found Apache POI, but it can be used only to work with Microsoft documents. Is there, for example a buffer, where can I send my letters or chars in ASCII? And next to be shown in my document or note?
Is there, for example a buffer, where can I send my letters or chars in ASCII?
Yes. It's called the Clipboard. You can call Toolkit.getDefaultToolkit() and then use Toolkit.getSystemClipboard() to get it.
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents("Some ASCII Text", this);
Note that this is the same buffer used for copy (ctrl-c) and paste (ctrl-v) (or their platform specific counterparts).
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
In My app I want to have an external file for saving my settings, item tags , etc. (for using it in outside of app like sending it on another device and so on).
after researching a lot I came to have a text file like this:
settings.txt
"Item1" : "data1"
"Item2" : "data2"
...
now is it the best solution for my purpose?
and if it is, how am I supposed to get my data based on it's id (Item number) from this kind of text file? (I can do the writing part but have no idea how to retrieve it).
Thanks in Advanced.
Instead of your way, you can store the key and values in JSON format. That way it would be easier for you to parse the data and get the value based on the item number (key). You can even use Google's Gson lib o make things simpler. JSON.simple example – Read and write JSON will help as well.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
im stuck on a simple question, i want to display formatted text in a swing control and keep on adding new values into it, i don't want to use .setText(.getText + text) for personal reasons, (something like the append method for text area is what I am looking for) I've tried JEditorpane, Textpane but all of them do not have append method. Which swing control should I use?
While JEditorPane has no append method, you can certainly add text to its Document via its insertString(...) method, and I suggest that you look into doing this.
Edit
You ask:
it worked it out but it seems it works like setText, all the previous data vanishes.. how do i keep the previous data ?
Are you correctly passing in the first parameter, the offset? This should be the length of the current Document.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I need to write a report which may contain some Java code pieces. I need the code to appear colored and line numbered. How can I do this ?
Go to http://hilite.me/ and copy from the preview pane directly to word (tested with MS Word2007). Supports line numbering, but not well. Quite good for snippets.
One way is to copy & paste directly from Eclipse. It preserves all the color formatting.
- Well you can directly copy the things from an IDE to your Word Document.
- And please make sure that you have switched on the Line Numbering of the Editor in the IDE before copying the code.
try to use this:
http://quickhighlighter.com/
select with the line numbers copy and paste
You can also use another online formatting tools, (http://stackoverflow.com/questions/206441/online-code-beautifier-and-formatter) but if you want the coloring to work after inserting to a word document, the highlihted source code html source must be inline styled.
You can copy with colors, but first you have to open all fold otherwise colors gone.
Line numbering copy is not working from Eclipse.
Explanation with example:
https://cmanios.wordpress.com/2012/03/08/copypaste-source-code-from-eclipse-to-microsoft-word/