Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to write a message in red colour on the log file in java using logger.debug method,is there any way to do it?
Logs don't support styled text! The software used to display them might use some cleverness to color different parts differently, but that is done purely in the software.
Logging itself is just plain text with no means of displaying a message in a particular colour (think of it as a txt file). So if you really want colour in your logs you need to encode that as formatting information which can later be interpreted by a text reader, log viewer or web browser.
Probably the easiest would be to use HTML for this. This could for example look like this:
<span class="error">02.01.13 14:23 Something bad happend</span>
<span class="info">02.01.13 14:24 This is just an info message</span>
and additionally providing a CSS file containing the styling information.
.info{ color: #000000; }
.error{ color: #FF0000; font-weight:bold;}
You could look for a plugin to your IDE if you want colorized logs.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I'm trying to find a html map in a HTMLDocument:
<html>
<map name="imagemap"></map>
</html>
With hdoc my HTMLDocument, I tried the following to get the map but it keeps returning null:
hdoc.getElement(hdoc.getDefaultRootElement(), HTML.Attribute.NAME, "imagemap")
Am I doing something wrong? How do I get the map?
You can't get the <map> nodes with getElement. They all get deleted by the HTML interpreter, even those in use.
Instead, use
((Hashtable) hdoc.getDocumentProperties().get("__MAP__")).get("#imagemap");
Unfortunately, the Map you get from this is a package-private class, so you can't use the data unless you do some reflection.
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 8 years ago.
Improve this question
We explored so many API's like tika,Pdfbox and itextpdf to extract page number from pdf file but we did not able to do this. In itextpdf we got PdfPageLabels.getPageLabels(reader) but the behaviour of this method is not uniform.
The reason why you don't find any software that is able to extract page numbers from a PDF is simple: the concept of a page number doesn't exist in PDF.
Allow me to predict your response.
*"Wait a minute!" you say, "When I open a PDF in Adobe Reader, I can clearly see a page number in the document!"
Well yes, you can see that page number with your eyes and your human intelligence, but to a machine that number is just some text drawn on a canvas. A machine consuming the document has no idea what all the glyphs and lines and shapes on a page are about. Hence, software can not give you the page number you see as a human. A machine doesn't know where to look!
If you know something about PDF, I can predict your next reply.
"Wait a minute!" you say, "What about Tagged PDF? Doesn't Tagged PDF mean that the semantics of a document are stored along with the representation?"
Well yes, when a PDF is tagged a snippet of text knows that is is part of a title, or a paragraph, or a list,... But Tagged PDF is there to define the structure of the real content. Page numbers however, are not part of the real content. They are marked as artifacts along with headers, footers and other items on a page that are not considered being real content. There is no way to distinguish page numbers.
"Then what are these page labels about?" you ask.
Well, page labels are optional. They are present in some PDFs that are well conceived, but they will be absent in a large majority of the PDFs you'll find in the wild.
This is the long answer. The short answer is simple: You are asking for something that is impossible (in general, not only with iText, Tika, PdfBox, or any other tool you might try).
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am trying to do my own program and what the basis of what I want is to use some sort of slider to take characters to different buildings. I essentially have a one long vertical road with my bus (which is what the slider will be). I know the general icon for a JSlider is a small pentagon that can be dragged to different values. I was just wondering, is there a way to change that pentagon icon into something of my choice?
You'll need to extend the BasicSliderUI and override paintThumb() to render the desired Shape. This example renders a triangle using drawLine().
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I created a swing application which has a string named textField, and I need to append in a string named textArea. My Problem is; when it appends, it doesn't align, since the names are different .
I want to make it accept 25 characters only, and if less than 25 were entered they are filled with spaces.
Is there any way this can be done? I Have been on it since morning without making any headway.
Any suggestion would be greatly appreciated, thanks in advance.
Every Text Component in java associates with a model to maintain it's text content known as Document. A Document has: DocumentListener to listen to changes made to it which generates event on it's content update. you can also use DocumentFilter with Document to change how the text component's data is set. You can implement certain customizations either by installing a document filter or by replacing a text component's document with one of your own.
Check out the example and tutorial:
How to write DocumentListener
Implementing a Document Filter
DocumentSizeFilter
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.