Java IO学习FileInputStream的read方法出现(无法将类 com.sun.org.apache.xpath.internal.operations.String中的构造器 Stri
2021/4/10 1:25:14
本文主要是介绍Java IO学习FileInputStream的read方法出现(无法将类 com.sun.org.apache.xpath.internal.operations.String中的构造器 Stri,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
学习IO框架中的FileInputStream的read方法过程中出现了问题,下面把代码先放出来:
package com.IOclass.demo01; import com.sun.org.apache.xpath.internal.operations.String; import java.io.FileInputStream; /** * 演示FileInputStream的使用 * 文件字节输入流 * @author lxw * */ public class Demo1 { public static void main(String[] args) throws Exception{ //1.创建FileInputStream,并指定文件路径 FileInputStream fis=new FileInputStream("d:\\aaa.txt"); //2.1读取文件(单个字节读取) // fis.read() // int data=0; // while ((data= fis.read())!=-1){ // System.out.print((char)data); // } //2.2一次读取多个字节 // byte[] buf=new byte[3]; // // int count=fis.read(buf); // System.out.println(new String(buf)); // System.out.println(count); // // int count2=fis.read(buf); // System.out.println(new String(buf)); // System.out.println(count2); // // int count3=fis.read(buf); // System.out.println(new String(buf,0,count3)); // System.out.println(count3); //2.3一次性读取多个字节的第二种表现形式 byte[] buf=new byte[3]; int count =0; while ((count=fis.read(buf))!=-1){ System.out.println(new String(buf, 0, count)); //出现错误地点!鼠标移到此处显示:Expected 0 arguments but found 3 } //3.关闭 fis.close(); System.out.println(); System.out.println("执行完毕"); } }
java: 无法将类 com.sun.org.apache.xpath.internal.operations.String中的构造器 String应用到给定类型;
需要: 没有参数
找到: byte[],int,int
原因: 实际参数列表和形式参数列表长度不同
原因分析:
是代码编辑器自动加上了com.sun.org.apache.xpath.internal.operations.String包,但是String的构造方法在java.lang.String包下,所以导致了导入的包是错误的。
解决方案:
只要将代码开头的包***com.sun.org.apache.xpath.internal.operations.String***删除即可
这篇关于Java IO学习FileInputStream的read方法出现(无法将类 com.sun.org.apache.xpath.internal.operations.String中的构造器 Stri的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-15鸿蒙生态设备数量超8亿台
- 2024-05-13TiDB + ES:转转业财系统亿级数据存储优化实践
- 2024-05-09“2024鸿蒙零基础快速实战-仿抖音App开发(ArkTS版)”实战课程已上线
- 2024-05-09聊聊如何通过arthas-tunnel-server来远程管理所有需要arthas监控的应用
- 2024-05-09log4j2这么配就对了
- 2024-05-09nginx修改Content-Type
- 2024-05-09Redis多数据源,看这篇就够了
- 2024-05-09Google Chrome驱动程序 124.0.6367.62(正式版本)去哪下载?
- 2024-05-09有没有大佬知道这种数据应该怎么抓取呀?
- 2024-05-09这种运行结果里的10.100000001,怎么能最快改成10.1?