|
You have a reference to one or more data structures when you load and play the wave file. Those take memory, both for the structures and the content of the wave file.
Each time this happens in your while loop you create those.
They never go away.
So you run out of memory.
You need to modify your code so it loads the wav file once and only once.
|
|
|
|
|
Hello India 123
Demo India
|
|
|
|
|
So being nice I will presume that either this was just a test message or it was not understand how to ask a question.
If the first then probably should delete.
If the second then a question should asked with details about it.
|
|
|
|
|
Hello!
In the next code, I've made a singly linked list.
In the AddNODE line(obj1) I called the AddNODE function, function which receives as parameter an object obj1 of type NODE.
The problem is the AddNODE(NODE newNode) function.
This newNODE must be an object or I think it would be like this.
Can you help me ?
class Persons
{
public String firstName;
public String secondName;
public String CNP;
public String Email;
};
class NODE
{
private NODE next;
public Persons box = new Persons();
public NODE(String firstName, String secondName, String CNP, String Email)
{
box.firstName = firstName;
box.secondName = secondName;
box.CNP = CNP;
box.Email = Email;
}
public NODE GetNext()
{
return next;
}
public void SetNext(NODE next)
{
this.next = next;
}
};
class SinglyLinkedList
{
private NODE head;
public SinglyLinkedList()
{
head = null;
}
public boolean isEmpty()
{
return head == null;
}
public void AddNODE(NODE newNode)
{
NODE temp = null;
if (isEmpty())
head = temp = newNode;
else
{
temp.SetNext(newNode);
temp = newNode;
}
temp.SetNext(null);
}
public void Print()
{
NODE temp = head;
while (temp != null)
{
System.out.print("\n First Name : " + temp.box.firstName);
System.out.print("\n Second Name : " + temp.box.secondName);
System.out.print("\n CNP : " + temp.box.CNP);
System.out.print("\n Email : " + temp.box.Email);
temp = temp.GetNext();
System.out.print("\n");
}
}
};
public class MyClass
{
public static void main(String args[])
{
SinglyLinkedList ptr = new SinglyLinkedList();
NODE obj1 = new NODE("Dragu", "Stelian", "1811226284570", "dragu_stelian@yahoo.com");
NODE obj2 = new NODE("Popescu", "Mircea", "1891226284462", "popescu.mircea@yahoo.com");
ptr.AddNODE(obj1);
ptr.AddNODE(obj2);
ptr.Print();
}
}
|
|
|
|
|
Your AddNODE method does not take account of the situation when head Is not null . Also you should set the next node pointer to null For a newly created node.
|
|
|
|
|
Please check again
public boolean isEmpty()
{
return head == null;
}
public void AddNODE(NODE newNode)
{
NODE temp = null;
if (isEmpty())
head = temp = newNode;
else
{
temp.SetNext(newNode);
temp = newNode;
}
temp.SetNext(null);
}
I am getting this error:
Exception in thread "main" java.lang.NullPointerException
at SinglyLinkedList.AddNODE
|
|
|
|
|
Yes, because you are still not connecting the new nodes to the head pointer. Try drawing a picture of a correctly linked list to see what head needs to point to.
|
|
|
|
|
If you can't see the problem, use the debugger to step through your code.
NODE temp = null; if (isEmpty()) { <-- false, execute "else" block else { temp.SetNext(... <-- BOOM! temp is still null here.
You need to decide whether the new node belongs at the start of the list, or at the end of the list.
If it belongs at the start, you set its next node to be the head, and set the head to be the new node.
public void AddNODE(NODE newNode)
{
newNode.SetNext(head);
head = newNode;
}
If it belongs at the end, you need to find the last node in the list, and set that node's next node to be the new node. If the list is empty, then set the head to be the new node.
public void AddNODE(NODE newNode)
{
if (isEmpty())
{
head = newNode;
}
else
{
Node last = head;
Node temp = last.GetNext();
while (temp != null)
{
last = temp;
temp = last.GetNext();
}
last.SetNext(newNode);
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
how to connect the finger print scanner in java and how to store the database in sql server 2008 R2
|
|
|
|
|
1. Research the scanner. Learn about the APIs that exist to interface to it.
2. Create Java code to use the API in 1 which is appropriate to the app that needs to use it.
3. Create Java code for the database that is appropriate to the app that needs to use it.
4. Wire 2 and 3 into the app.
Could be other steps as well, such as if you have no idea how to do 3 then there would be another step to investigate various methodologies to use a database via Java.
Forgot to mention that what you store in the database actually depends on the data that the scanner returns. But regardless of the form it will be likely be 'binary' so the database will need a column that specifically stored binary data. So if you do not know the difference there you will need to investigate.
|
|
|
|
|
Member 13140443 wrote: how to connect the finger print scanner in java
Ask the manufacturer abd/or users forum.
Member 13140443 wrote: how to store the database in sql server 2008 R2
Learn SQL
Both parts are completely unrelated, there is nothing in SQL related to finger print scanners. It Java job to glue things together.
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
how the static keyword is used in real time project?
|
|
|
|
|
|
Member 13364717 wrote: how the static keyword is used in real time project?
Exactly the same way as with any other kind of project. Because the usage of static keyword do not depend in the kind of project.
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
I have created a program by using Java. And there is Login with MySql Database. In this Admin can log into the system by using Username and Password which is in the database. But , I want to use admin's Fingerprint instead of username and password. But, I have no idea how to do this. Then I have searched everywhere to find the useful sources and I didn't find anything useful.
So , Can I know how to do this ??
Is there any kind of Documentation or video tutorial ??
|
|
|
|
|
|
|
No..
BTW , ThnQ Very Much For your links !!
|
|
|
|
|
I am working on dotx file template to generate word documents using docx4j in java. I will be replacing some placeholders in dotx file with text which comes from database columns. But problem is one of my database field contains HTML code(rich text editor value), when I place this text in placeholder in template, generated document display as-is content of html. I want that HTML code to be rendered to be proper text with styles.
Cold you please let me know how can I achieve this?
Sample Code which I have written to replace placeholders:
ByteArrayOutputStream baos = null;
DataRequestVO dataRequest = null;
WordprocessingMLPackage wordMLPackageMain = null;
try {
dataRequest = reportDAO.fetchDocketData(dataRequestNO);
String templateFile = dataRequest.getReportType().getTemplatePath();
String fileName = dataRequest.getDocketNo() + " - " + dataRequest.getDataRequestNo() + "-" + dataRequest.getReportType().getReportName();
URL url = this.getClass().getClassLoader().getResource(templateFile);
String templateFilePath = url.toURI().getPath();
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new File(url.toURI().getPath()));
ContentTypeManager ctm = wordMLPackage.getContentTypeManager();
CTOverride override = ctm.getOverrideContentType().get(new URI("/word/document.xml"));
if (templateFilePath.endsWith("dotm")) {
override.setContentType(
org.docx4j.openpackaging.contenttype.ContentTypes.WORDPROCESSINGML_DOCUMENT_MACROENABLED);
} else {
override.setContentType(org.docx4j.openpackaging.contenttype.ContentTypes.WORDPROCESSINGML_DOCUMENT);
}
DocketReportHelper.prepare(wordMLPackage);
List<Object> texts = DocketReportHelper.getAllElementFromObject(wordMLPackage.getMainDocumentPart(),
Text.class);
DocketReportHelper.replacePlaceholder(texts, dataRequest.getDocketNo(), PLACEHOLDER_DOCKET_NO);
DocketReportHelper.replacePlaceholder(texts, dataRequest.getQuestion(), PLACEHOLDER_QUESTION);
DocketReportHelper.replacePlaceholder(texts, dataRequest.getResponse(), PLACEHOLDER_RESPONSE);
if ("yes".equalsIgnoreCase(dataRequest.getConfidential())) {
wordMLPackageMain = createConfHeaderFooter();
List<Object> listParamMain = wordMLPackage.getMainDocumentPart().getContent();
for (Object param : listParamMain) {
if (param instanceof P) {
wordMLPackageMain.getMainDocumentPart().addObject((P) param);
} else if(param instanceof JAXBElement) {
wordMLPackageMain.getMainDocumentPart().addObject((JAXBElement) param);
}
}
} else {
wordMLPackageMain = wordMLPackage;
}
baos = new ByteArrayOutputStream();
SaveToZipFile saver = new SaveToZipFile(wordMLPackageMain);
saver.save(baos);
replacePlaceholder method:
static void replacePlaceholder(List<Object> texts, String name, String placeholder) {
log.debug("placeholder : " + placeholder);
for (Object text : texts) {
Text textElement = (Text) text;
if (textElement != null && placeholder.equals(textElement.getValue())) {
textElement.setValue(name);
break;
}
}
}
Prepare method:
public static void prepare(WordprocessingMLPackage wmlPackage) throws Exception {
WordprocessingMLPackage.FilterSettings filterSettings = new WordprocessingMLPackage.FilterSettings();
filterSettings.setRemoveProofErrors(true);
filterSettings.setRemoveContentControls(true);
filterSettings.setRemoveRsids(true);
wmlPackage.filter(filterSettings);
log.debug(XmlUtils.marshaltoString(wmlPackage.getMainDocumentPart().getJaxbElement(), true, true));
org.docx4j.wml.Document wmlDocumentEl = wmlPackage.getMainDocumentPart().getJaxbElement();
Body body = wmlDocumentEl.getBody();
SingleTraversalUtilVisitorCallback paragraphVisitor = new SingleTraversalUtilVisitorCallback(
new TraversalUtilParagraphVisitor());
paragraphVisitor.walkJAXBElements(body);
log.debug(XmlUtils.marshaltoString(wmlPackage.getMainDocumentPart().getJaxbElement(), true, true));
}
|
|
|
|
|
Since no one else replied.
1. I would parse the html and handle a LIMITED set of attributes.
2. I would limit the size and refuse to handle anything over a certain limit. I would log an error to indicate it
3. For unknown attributes I would strip them and log a warning.
4. I would document (not code) what was allowed for html in that data slot.
|
|
|
|
|
I want to find a way to convert Microsoft's word to PDF on linux. My idea is to read each word, picture, or table first, and then write their structure into the PDF document. But when I read the format of the document and write it to PDF, only the pictures can be written and the styles are completely different from those in the document. I would like to ask a kind person if you have any experience in this field. Please give me some advice or guidance. Thank you!
|
|
|
|
|
The issue is not too complicated. Firstly you need to understand the structure of Word documents, and how different parts are formatted, and which fonts are used to render the text. You then need to learn how to reformat that information into the structures that a PDF document uses. There are various libraries around to do both parts, and Google will find you the details.
|
|
|
|
|
ok,thank you man,i'll try it
|
|
|
|
|
For me what worked easiest on Linux:
- install OpenOffice or LibreOffice (whatever your Linux distro has as the default)
- then use the PDF converter tool that comes with LibreOffice (or Open...)
It is a simple command line tool that has tons of options. For Word it should provide really decent output as long as you have no real complex stuff in it.
|
|
|
|
|
write a program for a bank employee .
so that when he enters his/her ID the system can tell him to which bank he belongs and what is his designation.Is he a manager , normal employee, sales person, cashier .
manager can perform all the tasks but cashier ca deposit/withdraw cash, sales person can only upload documents etc.
|
|
|
|