java-me

How to trim the whitespace from a string? [duplicate]

China☆狼群 提交于 2019-11-26 20:53:43
This question already has an answer here: Strip Leading and Trailing Spaces From Java String 6 answers I am writing this function for a J2ME application, so I don't have some of the more advanced / modern Java classes available to me. I am getting java.lang.ArrayIndexOutOfBoundsException on this. So, apparently either it doesn't like the way I've initialized the newChars array, or I'm not doing something correctly when calling System.arraycopy . /* * remove any leading and trailing spaces */ public static String trim(String str) { char[] chars = str.toCharArray(); int len = chars.length; //

J2ME/Blackberry - how to read/write text file?

痴心易碎 提交于 2019-11-26 19:54:54
问题 please give me a sample code for read/write text file in blackberry application. 回答1: My code snippet for string read/write files: private String readTextFile(String fName) { String result = null; FileConnection fconn = null; DataInputStream is = null; try { fconn = (FileConnection) Connector.open(fName, Connector.READ_WRITE); is = fconn.openDataInputStream(); byte[] data = IOUtilities.streamToBytes(is); result = new String(data); } catch (IOException e) { System.out.println(e.getMessage());

AES Encryption/Decryption with Bouncycastle Example in J2ME

泪湿孤枕 提交于 2019-11-26 19:48:46
问题 i want to Encrypt and Decrypt data in J2ME using AES Algorithm with bouncy castle can any one give me sample code for that i want to use ECB with PKCS5Padding Thanks in Advance. 回答1: I'm sure there are examples out there but I haven't found them. Here are a few hints to help you get started. You need to learn how to connect the BC classes together. First, get the bouncycastle source code and be prepared to look at it when you have questions. It's actually very readable so don't be afraid to

What is the difference between strings allocated using new operator & without new operator in java J2ME?

你说的曾经没有我的故事 提交于 2019-11-26 17:16:49
问题 what is the Difference between String str=new String("Thamilan"); and String str="Thamilan"; in java J2ME. 回答1: In first case new object will be created always, in second case object from a string pool can be reused. Read more about String pool here: What is String pool? 回答2: The difference is that the new String creates a new object with the same value as the literal passed in: String s = "abc"; String t = new String("abc"); System.out.println(s==t); //false String u = "abc"; String v = "abc

Best practice for storing large amounts of data with J2ME

巧了我就是萌 提交于 2019-11-26 16:37:22
问题 I am developing a J2ME application that has a large amount of data to store on the device (in the region of 1MB but variable). I can't rely on the file system so I'm stuck the Record Management System (RMS), which allows multiple record stores but each have a limited size. My initial target platform, Blackberry, limits each to 64KB. I'm wondering if anyone else has had to tackle the problem of storing a large amount of data in the RMS and how they managed it? I'm thinking of having to

How do I split strings in J2ME?

喜欢而已 提交于 2019-11-26 16:35:49
问题 How do I split strings in J2ME in an effective way? There is a StringTokenizer or String.split(String regex) in the standard edition (J2SE), but they are absent in the micro edition (J2ME, MIDP). 回答1: There are a few implementations of a StringTokenizer class for J2ME. This one by Ostermiller will most likely include the functionality you need See also this page on Mobile Programming Pit Stop for some modifications and the following example: String firstToken; StringTokenizer tok; tok = new

Java obfuscation - ProGuard/yGuard/other? [closed]

对着背影说爱祢 提交于 2019-11-26 16:34:09
问题 This is along similar lines as these recent questions: Best Java Obfuscation Application For Size Reduction Creating non-reverse-engineerable Java programs However, one ends up recommending yGuard and the other ProGuard but neither mention both. I wonder if we could get a comparison of each one and hear peoples experiences from both sides of the fence. Looking at this comparison chart on the ProGuard website its clearly angled towards ProGuard. But what about real-world experience of each -

Audio spectrum analysis using FFT algorithm in Java

白昼怎懂夜的黑 提交于 2019-11-26 15:56:40
问题 I want to analyze the spectrum of an audio file in Java (ME). I want to draw spectrum as some media players do. But I don't understand some points: Input for FFT algorithm, which I have to get from the audio file. I don't now what it is called, what it is and more important, I don't know how to get it. Output: if input is an array (range?) I obtain other array, and it have range: 0-1, right (or not)? So what I have to do with it? 回答1: You need a few additional steps in addition to the FFT.

How to parse the JSON response in Blackberry/J2ME?

自闭症网瘾萝莉.ら 提交于 2019-11-26 14:26:52
问题 I want to parse the response coming from the server in JSON format. I have done some googling but i can't find any library or jar kind of thing. Everywhere there is provided open source code as zip file. How can i achieve this? if there is no jar available for blackberry then how to use that open source code in my application?? 回答1: There is an open source JSON for J2ME API on Mobile and Embedded Application Developers Project Also you can download JSON ME (Zip file) at JSON.org not supported

JSON parser for J2ME

余生颓废 提交于 2019-11-26 14:23:56
问题 I need a basic JSON parser that works with J2ME / CLDC 1.1. A Google search returns tons of answers on this (some even on stackoverflow), but it appears that all point to libraries and solutions that are no longer available (for example, lots point to an implementation that is supposed to be on the json.org site, but at least I can't find anything that isn't J2SE only there). My best hope so far is the source linked here: https://meapplicationdevelopers.dev.java.net/mobileajax.html, but from