80,359
社区成员
发帖
与我相关
我的任务
分享
package com.example.ini;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
//加载输入输出库
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Map.Entry;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import android.os.Environment;
import java.io.File;
import java.io.IOException;
import org.dtools.ini.*;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//插入自己的代码
boolean sdCardExist = Environment.getExternalStorageState()
.equals(android.os.Environment.MEDIA_MOUNTED); //判断sd卡是否存在
if (sdCardExist)
{
//sdDir = Environment.getExternalStorageDirectory();//获取跟目录
File sdCardDir = Environment.getExternalStorageDirectory();
System.out.println("sdCardDir = "+sdCardDir);
// String filename = "/sdcard/" + "T.ini";
//String filename=sdCardDir+"/"+"T.ini";
IniFile ini = new BasicIniFile(false);// 不使用大小写敏感
IniFileReader reader = new IniFileReader(ini, new File(filename));
try {
reader.read();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
IniSection sec_sys = ini.getSection("system");
String stationNum = sec_sys.getItem("stationNum").getValue();
System.out.println("stationNum = " + stationNum);
IniSection sec_station = ini.getSection("station");
for (IniItem item : sec_station.getItems()) {
String name=item.getName();
String value=item.getValue();
System.out.println(item.getName() + " = " + item.getValue());
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
/* */ package org.dtools.ini;
/* */
/* */ import java.io.BufferedReader;
/* */ import java.io.File;
/* */ import java.io.FileInputStream;
/* */ import java.io.IOException;
/* */ import java.io.InputStreamReader;
/* */
/* */ public class IniFileReader
/* */ {
/* */ private File file;
/* */ private IniFile ini;
/* */
/* */ static String getEndLineComment(String line)
/* */ {
/* 52 */ if ((!isSection(line)) && (!isItem(line))) {
/* 53 */ throw new FormatException("getEndLineComment(String) is unable to return the comment from the given string (\"" +
/* 55 */ line + "\" as it is not an item nor a section.");
/* */ }
/* */
/* 58 */ int pos = line.indexOf(';');
/* */
/* 60 */ if (pos == -1) {
/* 61 */ return "";
/* */ }
/* */
/* 64 */ return line.substring(pos + 1).trim();
/* */ }
/* */
/* */ static String getItemName(String line)
/* */ {
/* 82 */ if (!isItem(line)) {
/* 83 */ throw new FormatException("getItemName(String) is unable to return the name of the item as the given string (\"" +
/* 85 */ line + "\" is not an item.");
/* */ }
/* */
/* 89 */ int pos = line.indexOf('=');
/* */
/* 92 */ if (pos == -1) {
/* 93 */ return "";
/* */ }
/* */
/* 96 */ return line.substring(0, pos).trim();
/* */ }
/* */
/* */ static String getItemValue(String line)
/* */ {
.......
/* 379 */ BufferedReader reader = new BufferedReader(
/* 380 */ new InputStreamReader(
/* 381 */ new FileInputStream(this.file), "UTF-8"));//在这里修改的。。。。。。原来是ASCII
/* */
........................
/* 542 */ reader.close();
/* */ }
/* */ }
/* Location: E:\development\sourcecode\android\ini读取jar包\org.dtools.javaini-v1.1.00.jar
* Qualified Name: org.dtools.ini.IniFileReader
* JD-Core Version: 0.6.2
*/
然后 我需要把java
我需要把IniFileReader.java文件编译成IniFileReader.class文件
使用 javac IniFileReader.java
结果编译出错了 :
内容如下:
>javac IniFileReader1.java
IniFileReader1.java:9: 错误: 类IniFileReader是公共的, 应在名为 IniFileReader.jav
a 的文件中声明
/* */ public class IniFileReader
^
IniFileReader1.java:12: 错误: 找不到符号
/* */ private IniFile ini;
^
符号: 类 IniFile
位置: 类 IniFileReader
IniFileReader1.java:140: 错误: 找不到符号
/* */ public IniFileReader(IniFile ini, File file)
^
符号: 类 IniFile
位置: 类 IniFileReader
IniFileReader1.java:17: 错误: 找不到符号
/* 53 */ throw new FormatException("getEndLineComment(String) is unable t
o return the comment from the given string (\"" +
^
符号: 类 FormatException
位置: 类 IniFileReader
IniFileReader1.java:33: 错误: 找不到符号
/* 83 */ throw new FormatException("getItemName(String) is unable to retu
rn the name of the item as the given string (\"" +
^
符号: 类 FormatException
位置: 类 IniFileReader
IniFileReader1.java:49: 错误: 找不到符号
/* 115 */ throw new FormatException("getItemValue(String) is unable to ret
urn the value of the item as the given string (\"" +
^
符号: 类 FormatException
位置: 类 IniFileReader
IniFileReader1.java:75: 错误: 找不到符号
/* 165 */ throw new FormatException("getSectionName(String) is unable to r
eturn the name of the section as the given string (\"" +
^
符号: 类 FormatException
位置: 类 IniFileReader
IniFileReader1.java:158: 错误: 找不到符号
/* 374 */ IniSection currentSection = null;
^
符号: 类 IniSection
位置: 类 IniFileReader
IniFileReader1.java:165: 错误: 找不到符号
/* 388 */ Commentable lastCommentable = null;
^
符号: 类 Commentable
位置: 类 IniFileReader
IniFileReader1.java:169: 错误: 已在方法 read()中定义了变量 line
/* 395 */ String line = line.trim();
^
IniFileReader1.java:217: 错误: 找不到符号
/* 482 */ throw new FormatException("An Item has been read,before any
section.");
^
符号: 类 FormatException
位置: 类 IniFileReader
IniFileReader1.java:223: 错误: 找不到符号
/* */ IniItem item;
^
符号: 类 IniItem
位置: 类 IniFileReader
IniFileReader1.java:233: 错误: 找不到符号
/* */ catch (InvalidNameException e)
^
符号: 类 InvalidNameException
位置: 类 IniFileReader
IniFileReader1.java:235: 错误: 找不到符号
/* */ IniItem item;
^
符号: 类 IniItem
位置: 类 IniFileReader
IniFileReader1.java:236: 错误: 找不到符号
/* 506 */ throw new FormatException("The string \"" +
^
符号: 类 FormatException
位置: 类 IniFileReader
IniFileReader1.java:241: 错误: 找不到符号
/* */ IniItem item;
^
符号: 类 IniItem
位置: 类 IniFileReader
16 个错误
E:\development\sourcecode\android\ini读取jar包>javac IniFileReader.java
IniFileReader.java:12: 错误: 找不到符号
private IniFile ini;
^
符号: 类 IniFile
位置: 类 IniFileReader
IniFileReader.java:139: 错误: 找不到符号
public IniFileReader(IniFile ini, File file)
^
符号: 类 IniFile
位置: 类 IniFileReader
IniFileReader.java:17: 错误: 找不到符号
throw new FormatException("getEndLineComment(String) is unable to return t
he comment from the given string (\"" +
^
符号: 类 FormatException
位置: 类 IniFileReader
IniFileReader.java:32: 错误: 找不到符号
throw new FormatException("getItemName(String) is unable to return the nam
e of the item as the given string (\"" +
^
符号: 类 FormatException
位置: 类 IniFileReader
IniFileReader.java:48: 错误: 找不到符号
throw new FormatException("getItemValue(String) is unable to return the va
lue of the item as the given string (\"" +
^
符号: 类 FormatException
位置: 类 IniFileReader
IniFileReader.java:74: 错误: 找不到符号
throw new FormatException("getSectionName(String) is unable to return the
name of the section as the given string (\"" +
^
符号: 类 FormatException
位置: 类 IniFileReader
IniFileReader.java:157: 错误: 找不到符号
IniSection currentSection = null;
^
符号: 类 IniSection
位置: 类 IniFileReader
IniFileReader.java:164: 错误: 找不到符号
Commentable lastCommentable = null;
^
符号: 类 Commentable
位置: 类 IniFileReader
IniFileReader.java:168: 错误: 已在方法 read()中定义了变量 line
String line = line.trim();
^
IniFileReader.java:215: 错误: 找不到符号
throw new FormatException("An Item has been read,before any section."
);
^
符号: 类 FormatException
位置: 类 IniFileReader
IniFileReader.java:221: 错误: 找不到符号
IniItem item;
^
符号: 类 IniItem
位置: 类 IniFileReader
IniFileReader.java:231: 错误: 找不到符号
catch (InvalidNameException e)
^
符号: 类 InvalidNameException
位置: 类 IniFileReader
IniFileReader.java:233: 错误: 找不到符号
IniItem item;
^
............
15 个错误
彻底蒙了。。。。。。怎么回事 ?
请高手帮忙指教一下非常感谢!这个对我来说很重要!在线等等回复!!睡不着 万分感谢!!
文件我发到网盘了:
https://yunpan.cn/c6H4SfFcBJtye (提取码:d5fc)