SimpleAttributeSet set = new SimpleAttributeSet(); Document doc = tp.getStyledDocument(); FontMetrics fm = tp.getFontMetrics(tp.getFont());//得到JTextPane 的当前字体尺寸 int paneWidth = tp.getWidth();//面板的宽度 String text = new String(bt, 0, len); try { for(int…
---恢复内容开始--- 1.获取文本:声明别量,指定文本路径,获取文本内容. string Text=System.IO.File.ReadAllText(@"C:\xxx\xxx\xxx\xxx.xxx//文本名称及后缀名"); Console.WriteLine(Text);//输出文本内容 2.将内容写入文本 string txtresult;//定义变量 using (StreamReader sr = new StreamReader(@"c:\users\adm…