Hai,
I am using Java GWT. In this i want to load one html file.
htmlPane.setContentsURL("http://www.chellasoftapp.com/ATBrowser/images/disclaimer.html");
htmlPane.setContentsURL("images/disclaimer.html");
Which one be the faster? How is it works?
In images folder of WAR I placed that html file. Is it correct place? Or Where can i upload this?
Give suggestion for this issue.
Thanks in advance.
Regards,
Sathya.A
This solution:
htmlPane.setContentsURL("http://www.chellasoftapp.com/ATBrowser/images/disclaimer.html");
has quite big disadventage. It doesn't work in development on local machine.
I would use
htmlPane.setContentsURL(GWT.getModuleBaseURL() + "/images/disclaimer.html");
This one always works, doesn't matter if your application is at http://www.chellasoftapp.com/ATBrowser/ or at URL root: http://www.chellasoftapp.com/
Can you put .html file into images directory? Yes you can, and technically it is still valid, however, it is not readable and not obvious. I.e. it is hard to understand for other developers.
Related
Sup!
I'm trying to understand the concepts and differences between them to load and save files, and trying to figure out the best way to load files with a program I'm making (a database). I'm using Java, but try to help me in a more general way, if possible. Whatever help I get is a lot welcome and I thank you already for it.
I know there is "File Reader" in Java and a lot of programs use files in .txt format. I tried to open a .doc file with Notepad, just to see what would happen, and NOTHING was a text. I expected that, not everything though.
I just don't know how to make a file that is not a .txt. How that happens?
This is a big one. When I load a file, should I load all its content and let it ready for use, or should I just keep the file path and read from it as I use, using offsets and pointers starting from the file path? How should I do this either way?
In this database program of mine, some things will be images (for example), and if I were to use a .txt, I would give each image a label that the program would read and then interpret it like the label of the image, and then get the image. How could I do that?
I was sure I had more questions. If I do I ask again.
Once more, thanks in advance for the attention and help.
When it comes to the .txt bit, all "plain text" will work. Just change the file extension to .ini or .sql (if sql is installed) and change it in your filepath too.
I am new to Android development and have been struggling with a problem. I have been trying to learn how to save user inputs to file. I have asked a similar answer and ended up figuring out a solution although it didn't work out the way I want. I have been searching high and low about how to write files to xml. I would to have a user be able to save, add, retreive, and be able to remove items from an XML file. I think the problem I am having as far as learning this is I'm not sure what the processes are call to properly look for a solution. This isn't for school work, I'm not looking for anyone to write up some code for me. What I am hoping for is proper terminology, maybe a link to some helpful information and such. I believe this process is called parsing, and you can add to XML through appending, not sure about much after this. Thank you in advance to anyone who can offer assistance.
To have the XML always available for the app you should put it in the "assets" folder. You should copy-paste the xml file to modify it, to ensure the file won't be corrupted afterwards.
First you have to copy the xml to the sdcard (preferably to a folder with your app name as folder name), you can use this to learn how to copy a file. After you have done that you can use the JDOM Parser to modify that xml file.
Put the xml after the modification back in the assets folder.
I'm in doubt about something. I'm developing a Java Desktop application and I have a problem.
I need to get the current local folder that my application (jar file) is in user system. And after this, to search inside of this same folder for some files (like all .txt file, for example). And finally, get the name of only one of this files and converts to string.
Someone can help me?
Antecipate thanks.
May be the getCanonicalPath() and getProperty() functions could help you, since you don't show any code I can't make you any example, but may be looking this could help you a little.
And also there is a similar question here
I'm currently developing an application for a company which includes livescoring. The XML-files I access (from the net like: "http://company.com/files/xml/livescoring.xml") are not intended to be public and should only known to me.
I was wondering if it is possible for anyone to decode the .apk file and read my original .java files (which include the link to the XML files).
So, I renamed the .apk file to .zip and could access the "classes.dex", which seemed to include the .java files (or classes). Googling led me to a tool named "AvaBoxV2" which decoded this "classes.dex" file. Now I have a folder including an "out" folder where files named .smali exist. I opend one of these with an editor and finally there is the link to the xml file. Not good. :(
Is there a way to encrypt my app or the classes.dex file? I don't want to tell that company, that anyone can access the original xml-files. Maybe signing the app probably helps?
Also, do you know a really noob-friendly tutorial to prepare apps (signing, versioning,...) for Google Market?
Thanks in advance!
The .java source code is not included in the APK.
It is possible to disassemble the Dalvik bytecode into bytecode mnemonics using a tool like baksmali, but there's no way a user can recover the original .java source.
Furthermore, you can use a tool like proguard (included in the Android SDK) to obfuscate your byte code, making it hard to interpret the behavior of the disassembled bytecode.
You can make small tricks too, like storing the link string in some sort of obfuscated form, and then de-obfuscating it at run-time in your app (a simple example would be to use base 64 encoding, but someone could probably reverse that quickly if they wanted to).
That said, it's pretty trivial for someone to run tcpdump and sniff the network traffic between your device and the server, and get the URL that way, so there's no way to completely prevent anyone from getting this value.
Yeah, its impossible to fully prevent something like this. Its the same on a desktop application, or any other application.
As mentioned, obfuscation will help, but people who are persistent can still get past it. Especially for something like a url like that.
One solution of making it much more tricky for hackers is to use PHP on your webserver and some sort of token system to determine if the request is coming from your app or not... That would get a bit tricky though, so I don't really suggest it.
I have this code on an applet. The applet works ok, but I get a lot of unnecessary duplicate download. In particular, I have noticed that each "getResource" triggers a download of the .JAR file.
static {
ac = new ImageIcon(MyClass.class.getResource("images/ac.png")).getImage();
dc = new ImageIcon(MyClass.class.getResource("images/dc.png")).getImage();
//...other images
}
How can this be avoided?
Simply removing all instances of URLConnection.setDefaultUseCaches(false) will solve the problem.
Please refer for more details.
http://java-junction.blogspot.com/2009/11/applet-jar-caching-not-working.html
Do you include the applet to a HTML page? If so, try to enable the JAR caching, as is described here: http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/applet_caching.html
If that does not help for some reason :) perhaps expose your resources / images along your applet JAR on a web server and reach them using separate HTTP requests (yes, its ugly and yes, it does not reduce number of needed downloads, but it at least reduces the amount of data that need to be transferred).
Only a workaround:
You could put your images in a zip file inside the jar, get that using a ZipInputStream and extract the images from there.
Which Java VM do you use? And which Server do you use?
There is a bug in the browser plugin on Linux.
If the server does not send the modified date then Java can not cache the jar file.
If your applet always downloads the jar even though jar is cached, make sure you have not disabled the URLConnection's caching via the API: URLConnection.setUseCaches and URLConnection.SetDefaultUseCaches.
ImageIcon's underlying mechanism for fetching the resource is a URLConnection. Calling URLConnection.setDefaultUseCaches(false), sets a "part of the static state of all URLConnections" which cause the JRE to ignore the cache and redownload the entire jar every time it accessed.
Simply removing all instances of setDefaultUseCaches will solve the problem.
this is a repost from: http://java-junction.blogspot.com/2009/11/applet-jar-caching-not-working.html