codenameone的替代方法 [英] Alternative Methods in codenameone

查看:230
本文介绍了codenameone的替代方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用CodeNameOne通过Netbeans设计一个应用程序,并遇到了一些问题,特别是找不到符号编译错误。经过进一步的研究,我发现它是由于CNO不支持某些库/ misc。

I have been designing an application using CodeNameOne via Netbeans and have encountered some issues, notably the "cannot find symbol" compile-error. After further research, I discovered that it was due to CNO not supporting certain libraries/misc.

我想知道是否有其他方法可以使用以下库/执行任务:

I was wondering if there were alternate ways to use the following libraries/perform tasks:

(从文件中读取)
import java.io.File;
symbol:class File
location:package java.io

(Read from file) import java.io.File; symbol: class File location: package java.io

(抛出FileNotFoundException)
import java.io. FileNotFoundException异常;
symbol:class FileNotFoundException
location:package java.io

(Throw FileNotFoundException) import java.io.FileNotFoundException; symbol: class FileNotFoundException location: package java.io

(读取数据)
import java.util.Scanner;
symbol:class Scanner
location:package java.util

(Read data) import java.util.Scanner; symbol: class Scanner location: package java.util

(基于数学的函数)
符号:方法pow(double, int)
location:class Math

(Math-based functions) symbol: method pow(double,int) location: class Math

(创建格式化字符串)
symbol:方法格式(字符串)
location:class String

(Create formatted Strings) symbol: method format(String) location: class String

推荐答案

我不能肯定你提供的所有例子,但你应该考虑查看 CN1 API Javadocs ,了解如何以他们的方式执行此操作。

I can't say for sure about all the examples you provided but you should consider looking into the CN1 API Javadocs for information on how to do it "their way".

例如,当谈到文件时, Javadocs 说:


java.io的主要原因.File& java.io.FileInputStream不是直接支持的
与这两个
API的丰富性有很大关系。它们有效地允许在任何地方保存文件,但移动
设备的限制性更强,并且不允许应用程序查看/修改其他应用程序拥有的
文件。

The main reason java.io.File & java.io.FileInputStream weren't supported directly has a lot to do with the richness of those two API's. They effectively allow saving a file anywhere, however mobile devices are far more restrictive and don't allow apps to see/modify files that are owned by other apps.

所以,答案是,使用他们的。同样,搜索CN1 Javadocs以了解使用其API执行所需操作的适当方法。

So, the answer to that one is, use theirs. Similarly, search the CN1 Javadocs to learn the appropriate ways to do what you need using their APIs.

您还可以参考开发人员指南,例如:大多数基于文件的操作应该通过存储 FileSystemStorage 执行,这两者都包括在内此处。您应该非常小心使用 java.io.File 的代码,因为这可能依赖于桌面特定的行为。

You can also refer to the developer guide e.g. most file based operations should be performed either thru Storage or FileSystemStorage both of which are covered here. You should be very careful with code that uses java.io.File as this might rely on desktop specific behaviors.

FileNotFoundException 可以替换为 IOException (这是一个无论如何, IOException 的子类。

FileNotFoundException can be replaced with IOException (it's a subclass of IOException anyway).

没有直接相当于扫描器但是有内置的JSON,XML,CSV和&解析器解析器。属性。

There is no direct equivalent to Scanner but there are builtin parsers for JSON, XML, CSV & Properties.

一些数学函数位于 MathUtil ,包括 Math.pow(double,double)

Some of the math functions are in MathUtil that includes Math.pow(double, double).

不等同于Java SE的 format()方法。您需要连接字符串。

There is no equivalent to the format() method of Java SE. You would need to concatenate strings instead.

请注意,如果您发布一些代码作为问题,我们有时可以使用Codename One等效。

Notice that if you post some code as a question we can sometimes help with the Codename One equivalent.

这篇关于codenameone的替代方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆