How do I use XMLStreamWriter to write exactly what I put in? For instance, if I create script tag and fill it with javascript I don't want all my single quotes coming out as '
I have tried to write an Android application with an activity that should be launched from a different application. It is not a content provider, just an app with a gui that should not be listed among the installed applications. I have tried the code examples here and it seems to be quite easy to launch existing providers and so on, but I fail to figure out how to just write a "hidden" app and launch it from a different one.
The basic use case is:
App A is a normal apk launchable from the application list.
App B is a different apk with known package and activity names, but is is not visible or launchable from the application list.
App A launches app B using the package and class names (or perhaps a URI constructed from these?).
I fail in the third step. Is it possible to do this?
I'm developing a few custom ant tasks that all need to initialize the same objects. I wanted to initialize those object's in a common superclass that extends from Task, in the init() method. But I see from the lifecycle of an ant task that init() gets called before the tasks child elements and attributes are set. So all of the data I need for initializing those objects is unavailable during init(), if I am reading right.
So, why is init() called at this point? What do you even know that you could use in init()? What could it be used for?
(And is there some other method that I can rely on to be called before execute(), but after my data is available?)
Hi,
I'd like to know if it is "ok" to write a test without any "assert" in it. So the test would fail only when an exception / error has occured.
Eg: like a test which has a simple select query, to ensure that the database configuration is right. So when I change some db-configuration, I re-run this test and check if the configuration is right. ?
Thanks!
I know how to use comma in printf as grouping separator to print value in format like
1,000,000.00
to print it that way I'm using command
System.out.printf ("%,.2f", value);
but how to use space as grouping separator to format value like
1 000 000.00
I tried to find solution but solutions with using DecimalFormat look at now to complicate for me (beginner level). Is there as easy way as in example with comma to do it?
hello i am a student and i am doing my senior project it is about developing an application in j2me for scanning a barcode and extract the number of the barcode in a message to be send.
please i search the net but i cant found something usefull i am new at j2me if someone could help me with sourch code and how to create it i will be very thankfull my email is [email protected]
thanks in advanced
I have noticed from several web pages that apparently Spring 3.0 supports @Inject from JSR-330. As we would really like to use JSR-299 syntax for dependency injection in our libraries for both web apps and stand-alone applications, and have alternatives to Weld, it would be nice if Spring could do this.
Being a novice to Spring, I tried downloading the Spring Framework distribution and put all jars on the Eclipse build path. No Inject annotation so my existing test project using Weld did not compile.
Can this be done with Spring? What do I need to do to get it running?
(I am aware that Guice eventually will support this too. It is only in SVN for now, and if there is an official Spring release which can, that would be better.)
This question is not about 'best' barcode library recommendation, we use various products on different platforms, and need a simple way to verify if a given barcode is correct (according to its specification).
There are some free online bar code generators in the Internet, and I found many differences between their output and our library output regarding graphics and text field below the code. Now I am not sure which one is wrong, and before filing bug report I want to make sure how the correct barcode should look like.
We mainly need Code128 and UCC/EAN-128 with A/B/C subcodes. Which resource would you suggest?
Hi.
I'm testing a Swing GUI application using the UISpec4J testing framework. I'm testing validation code on a JTextField, but the framework does not support focus-change events, as it runs the application in a headless fashion.
The text field has a DocumentEvent attached to it that activates the validation code. I'm trying to figure out how to dispatch the document event manually to activate the validation code. Trying to dispatch focus or mouse events manually haven't been working for me.
Thanks for any help!
I'm creating a list of items from a file
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("H:/temp/data.csv")));
try {
List<Item> items = new ArrayList<Item>();
Item item = new Item();
String line = null;
while ((line = reader.readLine()) != null) {
String[] split = line.split(",");
item.name = split[0];
item.quantity = Integer.valueOf(split[1]);
item.price = Double.valueOf(split[2]);
item.total = item.quantity * item.price;
items.add(item);
}
for (Item item2 : items) {
System.out.println("Item: " + item2.name);
}
} catch (IOException e) {
reader.close();
e.printStackTrace();
}
Problem is the list is displaying the last line in the file as the value for all items.
I was writing two implementations of a linked list for an assignment, a doubly linked list and a circular doubly linked list. Now as the class representing a Link within the linked list is the same in both implementations, I want to use it in both.
Now I wonder which approach would be better:
Implement the Link class as a package private static member class in the first implementation and then use this class in the second implementation or make the Link class a package private class.
I recently acquired a Metrologic Barcode scanner (USB port), as everyone already knows it works as a keyboard emulator out of the box.
How do I configure the scanner and my application so that my app can process the barcode data directly? That is, I don't want the user to focus on a "Text field" and then process the data when the KeyPress event fires.
I'm building an application where space is at a premium. I'd really like to use JAXB's unmarshalling capabilities, but including the whole library is out of the question. Has anyone paired it down so that only the bits needed for unmarshalling are included?
Hi,
I'm getting a Null ArrayList in a program i'm developing. For testing purposes I created this really small example that still has the same problem. I already tried diferent Primary Keys, but the problem persists.
Any ideas or suggestions?
1-Employee class
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class Employee {
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
@Extension(vendorName="datanucleus", key="gae.encoded-pk", value="true")
private String key;
@Persistent
private ArrayList<String> nicks;
public Employee(ArrayList<String> nicks) {
this.setNicks(nicks);
}
public String getKey() {
return key;
}
public void setNicks(ArrayList<String> nicks) {
this.nicks = nicks;
}
public ArrayList<String> getNicks() {
return nicks;
}
}
2-EmployeeService
public class BookServiceImpl extends RemoteServiceServlet implements
EmployeeService {
public void addEmployee(){
ArrayList<String> nicks = new ArrayList<String>();
nicks.add("name1");
nicks.add("name2");
Employee employee = new Employee(nicks);
PersistenceManager pm = PMF.get().getPersistenceManager();
try {
pm.makePersistent(employee);
} finally {
pm.close();
}
}
/**
* @return
* @throws NotLoggedInException
* @gwt.typeArgs <Employee>
*/
public Collection<Employee> getEmployees() {
PersistenceManager pm = getPersistenceManager();
try {
Query q = pm.newQuery("SELECT FROM " + Employee.class.getName());
Collection<Employee> list =
pm.detachCopyAll((Collection<Employee>)q.execute());
return list;
} finally {
pm.close();
}
}
}
What would happen if an exception is thrown during the execution of finalize()?
Is the stack unwind like normally? Does it continue finalize() and ignore the exception? Does it stop finalize() and continue GC the object? Or something else?
I'm not looking for guidelines of using finalize() there are plently of pages explaining that.
I am trying to send a zipfile from my android application to our server and I keep getting a 411 length required error.
Here is the code that I am using to do that.
HttpPost post = new HttpPost("http://www.xyz.org/upload.json");
post.setHeader(C.constants.HTTP_CONTENT_TYPE, "application/octet-stream");
try {
FileInputStream fis = new FileInputStream("/data/data/org.myapp.appname/app_content.zip");
InputStreamEntity reqEntity = new InputStreamEntity(fis, -1);
post.setEntity(reqEntity);
String response = doPost(post);
Log.v(tag, "response from server " + response);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
What am I doing wrong here and may I also know how I can add more parameters with this post to send them to the server.
Suppose I decide to call acknowledgment() on a JMS message several times. Say the first call fails (for non-permanent reason). Does the success of the second (or any subsequent) call guarantee that the message is now acknowledged? Is the exact behavior of acknowledgement() specified anywhere?
Using axis1 it is possible to log incoming/outgoing soap messages by adding logging on HTTPSender in log4j.properties. After migrating to axis2 (version 1.4.1) I have a hard time figuring out how to accomplish the same kind of logging. I have tried to add logging on the axis2 package and org.apache.commons.httpclient but no logging is provided.
Any ideas?
TIA
Hi,
when I package my project with the Maven goal "package", the resources are included as well. They are originally located in the directory "src/main/resources".
Because I want to create an executable jar and add the classpath to the manifest, I'm using maven-jar-plugin.
I've configured it as the following likes:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>at.sozvers.stp.zpv.ekvkumsetzer.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
Why won't the jar file created with "jar:jar" include my resources as well. As far as I'm concerned it should use the same directories as the "package" goal (which are in my case inherited from the Maven Super POM).
We are currently discussing the Best Practice for placing the @Transactional annotations in our code.
Do you place the @Transactional in the DAO classes and/or their methods or is it better to annotate the Service classed which are calling using the DAO objects? Or does it make sense to annotate both "layers"?
So most of us know how to access an outer class from an inner class. Searches with those words give oodles of answered questions on that topic. But what I want to know is why the syntax is the way it is.
Example:
public class A
{
private class B
{
public void c()
{A.this.d();}
}
public void d()
{System.out.println("You've called d()! Go, you!");}
}
Why is it A.this.d()? It looks like this is a static field of class A, but... * am confused *
Forgive me if this is a repeat; like I said, searches with those words give how-answers.
Guys,
I"m trying to use Tyburn to do some BDD with JBehave and I've got a question about what Tyburn can do. Can Tyburn simulate Menu selections? Like Ive I want to say something like
@Then("when I select 'Start' from the Recording Menu)
selectMenu(Recording)
selectMenuItem(Start)
Is there a way to make this happen?
Thanks,
Joe
I created class NewProject extends JInternalFrame. Then I create New...Action named "NEW", localised in File menu. I put code NewProject p = new NewProject(); p.setVisible(true); to the ActionPerformed method of the action.
But when I run the module and click "NEW" in file menu, nothing appears.
Where can be problem?