问个问题,如果readRadius(String filename)
编译报错:
首先java中就没有In这个类,第二java方法中的参数怎么可以没有类型,又不是js函数。java读取文件有很多IO类可以用,建议你去了解一下Java IO的相关知识。
你怎么不把整个类的内容都截取出来呢,反正代码也不多
直接看代码:
public static String readFile(String fileName) {
String fileContent = "";
try {
File f = new File(fileName);
if (f.isFile() && f.exists()) {
InputStreamReader read = new InputStreamReader(
new FileInputStream(f), "utf-8");
BufferedReader reader = new BufferedReader(read);
String line;
while ((line = reader.readLine()) != null) {
//line = line + "
";
fileContent += line;
}
read.close();
}
} catch (Exception e) {
e.printStackTrace();
}
return fileContent;
}
public static String encode(String url) {
try {
String encodeURL = URLEncoder.encode(url, "UTF-8");
return encodeURL;
} catch (UnsupportedEncodingException e) {
return "Issue while encoding" + e.getMessage();
}
}
public static void main(String[] args) throws IOException {
String filePath = "C:/Users/Administrator/Desktop/urlencoding2.txt";
// toUtf8String(filePath);
String filecontext = readFile(filePath);
String encodeURL = encode(filecontext);
String path = "C:/Users/Administrator/Desktop/"; // 取得目录在服务器端的实际位置
// out.println(path+"<br>");
FileWriter fw = null;
try {
fw = new FileWriter(path + "/" + "decode_after1.txt");
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} // 建立FileWrite对象,并设定由fw对象变量引用
// 将字串写入文件
try {
fw.write(encodeURL);
System.out.println("已经写入");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
fw.close(); // 关闭文件
java里面没有In这个类啊