Posts by brow-joe • 2,144 points
69 posts
-
0
votes2
answers281
viewsA: My program gives error when the array value is null
Good afternoon, you can use the property has to validate whether the attribute exists within json. Follows: JSONArray jsonArray = null; for (int i = 0; i < jsonArray.length(); i++) { JSONObject…
-
1
votes2
answers368
viewsA: How can I extract the information from an XML that is stored in a String?
You can make a regular expression to take only the data you need. In the example above, with this input xml to capture the type and the url vc can do this way: String xml = "<opml…
-
1
votes1
answer399
viewsA: Error in relative python import
Try: from ..files.mymath import mysum In the case of mysum would be the def which is created within the mymath.py for example in a structure: mypackage/ __init__.py mymodule.py myothermodule.py the…
-
3
votes2
answers123
viewsA: Date to String to Pyhton conversion
You can use the .strftime('%Y-%m-%d') In this way: t = datetime.date(2017, 2, 1) t.strftime('%Y-%m-%d') Your answer will be: '2017-02-01'…
-
1
votes1
answer447
viewsA: Hierarchical selects. Parent-child relationship in the same table
Try to change your hql to: ("SELECT E FROM " + Product.class.getSimpleName() + " AS E" + " LEFT JOIN " + Product.class.getSimpleName() + " AS P" + " ON E.id = P.owner_id" + " WHERE P.owner_id IS…
-
2
votes3
answers192
viewsA: Swap String content for "$"
Missed using the exhaust \ public static void main(String[] args) { String texto = "teste {{texto}} teste"; String trocar = "_\\$_"; texto = texto.replaceAll("\\{\\{texto\\}\\}", trocar);…
-
18
votes2
answers6299
viewsA: What defines a stable sorting algorithm?
A sorting algorithm is considered stable when it manages to preserve the order of record of equal keys, in other words if the records appear in the ordered sequence in the same order they are in the…
-
1
votes1
answer550
viewsA: Is it possible to inject a bean into a Singleton with Enum?
The most practical way for you to inject dependencies within Enum is to create a component that will actually set these dependencies to be used as below: public enum ItemRemessaUtil { INSTANCIA;…
-
1
votes1
answer1179
viewsA: How do I sort string in the Insertion Sort method?
The method .compareTo returns an int (-1 for smaller, 0 for equal, and 1 for greater). This way, for you to compare you can use: while (j>0 && 0 == x.compareTo(a[j-1])) or while (j>0…
-
2
votes1
answer187
viewsA: Writing IP addresses to file, each IP on a different line using Python
Failed to insert line break " n", you can use .write("\n") for example: from scapy.all import * pkts = rdpcap("lalalao.pcap") for p in pkts: ## print p.time if IP in p: #if packet has IP layer…
-
1
votes1
answer813
viewsA: Runtime Error in Python
according to the report there is a bug present in Python version 2.6, basically a solution to this problem was changing the path of the pythonhome environment variable from python26 to python32…
-
7
votes1
answer17403
viewsA: What is the best way to concatenate strings in Python?
In Python strings are immutable and for this reason, when we concatenate two of them using the "+" operator a new string object is created and the original objects lose their references. One…
-
2
votes3
answers11849
viewsA: Restart application in Python
To restart your application you can create the following method: import sys import os def restart_program(): python = sys.executable os.execl(python, python, * sys.argv) then when you want to…
-
1
votes2
answers174
viewsA: How to load persistence.xml settings in Combopooleddatasource?
failed to include within the persistent pool boundary <property name="hibernate.c3p0.minPoolSize" value="10"/> <property name="hibernate.c3p0.maxPoolSize" value="20"/>…
-
3
votes1
answer1589
viewsA: Redeem values with equal class names using Selenium
Actually the problem is in find, in Selenium when you use driver.findElement by default he catches the first, in this case you can catch driver.findElements for example: List<WebElement>…
-
2
votes3
answers307
viewsA: Ignored line of code
This is because nextDouble does not consume the last new line character of your input and therefore the new line is consumed in the next call, one solution is to use the next() instead of…
-
2
votes1
answer299
viewsA: E-mail Sending Error using Hotmail as Commonsmail Java
I usually use it this way with java mail Properties propertie = new Properties(); propertie.put("mail.transport.protocol", "smtp"); propertie.put("mail.smtp.host", "smtp.live.com");…
-
0
votes1
answer111
views -
8
votes3
answers1090
viewsA: In programming, what is the actor model?
The actors are isolated, single-threaded components that encapsulate their state and behavior. This is very similar to the functioning of conventional messaging services, since actors receive input…